摘要:
232 用栈实现队列 class MyQueue { private Stack<Integer> stack1 = new Stack<>(); private Stack<Integer> stack2 = new Stack<>(); /** Initialize your data stru 阅读全文
摘要:
242 有效的字母异位词 class Solution { public boolean isAnagram(String s, String t) { int[] record = new int[26]; for (int i = 0; i < s.length(); i++) { record 阅读全文
摘要:
203 移除链表元素 //链表的节点删除通过前一个节点来移除当前节点 class Solution { public ListNode removeElements(ListNode head, int val) { ListNode dummyHead = new ListNode(0); dum 阅读全文
摘要:
35 搜索插入位置 //二分法 class Solution { public int searchInsert(int[] nums, int target) { int left = 0; int right = nums.length - 1; while (left <= right) { 阅读全文
摘要:
509 斐波那契数列 class Solution { public int fib(int n) { int[] dp = new int[n+1]; if (n <= 1) { return n; } dp[0] = 0; dp[1] = 1; for (int i = 2; i <= n; i 阅读全文