摘要:
今天是第十三天,是队列相关,难度不小 239. 滑动窗口最大值 class Solution { public int[] maxSlidingWindow(int[] nums, int k) { int n = nums.length; if(n<2){ return nums; } Deque 阅读全文
摘要:
第十天 今天开始学习stack相关 232. 用栈实现队列 class MyQueue { Stack<Integer> in; Stack<Integer> out; public MyQueue() { in = new Stack<>(); out = new Stack<>(); } pub 阅读全文
摘要:
第八天,从昨天看,难度应该会递加,今天是五道题,稍有挑战性了。 344. 反转字符串 class Solution { public void reverseString(char[] s) { int n = s.length; int i = 0; int j = n - 1; while(i< 阅读全文
摘要:
第三天是链表,要注意的是可以创建虚拟头节点来进行链表操作。 203. 移除链表元素 class Solution { public ListNode removeElements(ListNode head, int val) { ListNode temp = new ListNode(-1); 阅读全文
摘要:
今天是训练营第二天,包含了第一天双指针的扩展题 977. 有序数组的平方 class Solution { public int[] sortedSquares(int[] nums) { int n = nums.length; int[] res = new int[n]; int l = 0; 阅读全文
摘要:
算法训练营第一天,训练内容是二分查找和双指针。 704. 二分查找 ``` class Solution { public int search(int[] nums, int target) { int n = nums.length; int l = 0; int r = n; while(l< 阅读全文