This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LinkedList; | |
import java.util.Queue; | |
import java.util.Stack; | |
public class TreeMap_LevelOrder { | |
class BST<E extends Comparable<E>> { | |
private class Node { | |
public E e; | |
public Node left, right; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class Stack_MiniStack { | |
//声明一个data栈 | |
private static Stack<Integer> dataStack = new Stack<>(); | |
//声明一个min栈 | |
private static Stack<Integer> minStack = new Stack<>(); | |
//入栈 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class Queue_TwoStack { | |
private static Stack<Object> stack1 = new Stack<>(); | |
private static Stack<Object> stack2 = new Stack<>(); | |
public static void enqueue(Object item) { | |
stack1.push(item); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class LinkedList_removeLastKthNode { | |
public static class Node { | |
public int val; | |
public Node next; | |
// constructor | |
public Node(int val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class LinkedList_isPalindrome { | |
public static class Node { | |
public int val; | |
public Node next; | |
// constructor | |
public Node(int val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class LinkedList_Creation { | |
// 链表节点的定义 | |
public static class Node { | |
public int val; | |
public Node next; | |
public Node(int val) { | |
this.value = val; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Stack; | |
public class LinkedList_AddTwoList { | |
public class LNode { | |
public int val; | |
public LNode next; | |
// constructor | |
public LNode(int val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class LinkedList_del_Duplicatation { | |
public class ListNode { | |
public int val; | |
public ListNode next; | |
// constructor | |
public ListNode(int val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LinkedList_deleteNodeByVal { | |
public class LinkedList<E> { | |
private class Node{ | |
public E e; | |
public Node next; | |
public Node(E e, Node next){ | |
this.e = e; | |
this.next = next; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
三种可能: | |
1.头部部加node | |
2.中间加node | |
3.结尾加node | |
*/ | |
public class LinkedList_Add { | |
class LinkedList<E> { | |
// 定义node的property和method |