Skip to content

Instantly share code, notes, and snippets.

View shaobos's full-sized avatar

Shaobo Sun shaobos

  • Sunnyvale, California, US
View GitHub Profile
@shaobos
shaobos / reverse.java
Created March 5, 2023 05:24
Reverse linked list - Java
public class Node {
int val;
Node next;
public Node(int val) {
this.val = val;
this.next = null;
}
}
@shaobos
shaobos / reverse.py
Created March 5, 2023 05:26
Reverse linked list - Python
class Node:
def __init__(self, val):
self.val = val
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def add(self, val):
@shaobos
shaobos / reverse.js
Last active March 5, 2023 05:29
Reverse linked list - Javascript
class Node {
constructor(val) {
this.val = val;
this.next = null;
}
}
class LinkedList {
constructor() {
this.head = null;
@shaobos
shaobos / reverse.cpp
Created March 5, 2023 23:18
Reverse Linked List - C++
#include <iostream>
using namespace std;
struct Node {
int data;
Node* next;
};
class LinkedList {
private: