public static int topK(int[] arr, int k) { if (arr == null || k > arr.length || arr.length == 0 || k <= 0) { return -1;...
private TreeNode buildTree(Integer[] array, int index) { TreeNode treeNode; if (index < array.length) { Integer value =...
public class LRUCache<K,V>{ private final int cap; private final Map<K,V> map; private final LinkedList<K> list; public...
class Solution { public int lengthOfLIS(int[] nums) { if (nums == null || nums.length == 0){return 0;} int[] dp = new...
class CQueue { Stack<Integer> stack1; Stack<Integer> stack2; public CQueue() { stack1 = new Stack(); stack2 = new...
class Solution { public ListNode deleteNode(ListNode head, int val) { ListNode myHead = new ListNode(-1); myHead.next =...
剑指 Offer 27. 二叉树的镜像 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; *...
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; *...
剑指 Offer 30. 包含min函数的栈 class MinStack { Stack<Integer> stack1; Stack<Integer> stack2; /** initialize your data structure...
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val =...