每周总结3

动态规划专题,总结一下dp使用的特点 DP-easy系列题 Climbing Stairs(走一步还是走二步,考虑可能性的话是不是大多是+?sol[i] = sol[i-1] +

每周总结2

昨天做了到利用HashMap的Sum类型题,感觉其思路挺有意思的,联想到LeetCode第一题Two Sum的高效解法也是用的HashMap,

每周总结1

之前的每日算法更新结束,文章多了后,hexo编译好慢,而且每天写的话有点浪费时间,算法题还是每天在做,之后改成总结更新类的方式。 Tr

每日一刷68

简单的5到tree综合总结(104、98、101、102、108) 代码就不贴了,暂时就说说感想: - tree的题基本都是可以用递归做的,可

每日一刷67

241. Different Ways to Add Parentheses iven a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Example 1: 1 2 3 4 5 Input: "2-1-1" Output: [0, 2] Explanation: ((2-1)-1) = 0 (2-(1-1)) = 2 Example 2: 1 2 3 4 5 6 7 8 Input: "2*3-4*5" Output: [-34,

每日一刷66

138. Copy List with Random Pointer A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

每日一刷65

23. Merge k Sorted Lists Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: 1 2 3 4 5 6 7 Input: [ 1->4->5, 1->3->4, 2->6 ] Output: 1->1->2->3->4->4->5->6 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

每日一刷64

148. Sort List Sort a linked list in O(n log n) time using constant space complexity. Example 1: 1 2 Input: 4->2->1->3 Output: 1->2->3->4 Example 2: 1 2 Input: -1->5->3->4->0 Output: -1->0->3->4->5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

每日一刷63

61. Rotate List Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: 1 2 3 4 5 Input: 1->2->3->4->5->NULL, k = 2 Output: 4->5->1->2->3->NULL Explanation: rotate 1 steps to the right: 5->1->2->3->4->NULL rotate 2 steps to the right: 4->5->1->2->3->NULL Example 2: 1 2 3 4 5 6 7 Input: 0->1->2->NULL, k = 4 Output: 2->0->1->NULL Explanation: rotate 1 steps to

每日一刷62

160. Intersection of Two Linked Lists Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: 1 2 3 4 5 A: a1 → a2 ↘ c1 → c2 → c3 ↗ B: b1 → b2 → b3 begin to intersect at node c1. Notes: * If the two linked lists have no intersection at all,