Skip to content

Instantly share code, notes, and snippets.

@l3ngli
Created September 2, 2025 19:38
Show Gist options
  • Select an option

  • Save l3ngli/51a26f92a0f6a910084b1e6db2421339 to your computer and use it in GitHub Desktop.

Select an option

Save l3ngli/51a26f92a0f6a910084b1e6db2421339 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
class Node {
public:
int value;
Node* next;
Node(int value) {
this->value = value;
this->next = nullptr;
}
};
int main()
{
Node* head = nullptr;
Node* tail = nullptr;
Node* current = new Node(1);
head = current;
tail = current;
current = new Node(2);
current->next = head;
head = current;
current = new Node(3);
current->next = head;
head = current;
cout << head->value;
cout << head->next->value;
cout << head->next->next->value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment