Skip to content

SunnyGJing/Algorithm-note

Repository files navigation

一、题目简记

便于快速复习
分别按类别和按题号排列

按类别整理:

模式1:滑动窗口/动态规划

53.返回最大连续子数组(含负数)的和

方法:优化后的动态规划

# 循环内
cur_val = nums[i]>0 ? cur_val+nums[i] : nums[i]
max_val = max(max_val, cur_val)
659.将有序数组拆为数值连续的子序列(长度>=3)

方法:用哈希表模拟多个单调队列

# 初始化
hasht = collections.default(list)

# 数组遍历
pre_small = hasht.get(nums[i]-1, 0)
hasht[nums[i]].append(pre_small + 1)

hasht[nums[i]-1].remove(pre_small)

# 字典遍历
return False if i<3 for list in hasht.values() for i in list
1296.将无序数组拆为数值连续的子序列(长度=k)

方法:

# 初始化
return False if len(nums) % k

count = collections.Counter(nums)

# 字典不为空时 循环
start = min(count.keys())

return False if count[num+i]<count[num] for i in range(1,k)
count[num+i] -= count[num] for i in reversed(range(k,-1))

二、刷题计划与记录

2020.02计划:
周中每天刷10道题  
周末不刷题,只做总结和复习

2020.03计划:
每天上午做总结和复习1小时刷题3小时  
2.12 Wed. 未分类 [7]
  • 1. Two Sum
  • 15. 3Sum
  • 26. Remove Duplicates from Sorted Array
  • 80. Remove Duplicates from Sorted Array II
  • 83. Remove Duplicates from Sorted List
  • 844. Backspace String Compare
  • 977. Squares of a Sorted Array
2.13 Thur. 滑动窗口 [10/10] 已完成
  • 82. Remove Duplicates from Sorted List II
  • Google | Remove Duplicates from Unsorted Array
  • 316. Remove Duplicate Letters
  • 360. Sort Transformed Array
  • 16. 3Sum Closest
  • 259.ThreeSumSmaller
  • 713. Subarray Product Less Than K
  • 152. Maximum Product Subarray
  • 325. Maximum Size Subarray Sum Equals k
  • 560. Subarray Sum Equals K
2.14 Fri. 有序数组多指针 [6/10]
  • 1099. Two Sum Less Than K
  • 198. House Robber
  • 213. House Robber II
  • 337. House Robber III
  • 256. Paint House
  • 265. paint house ii
  • 238. Product of Array Except Self
  • 628. Maximum Product of Three Numbers
  • 974. Subarray Sums Divisible by K
  • 75. Sort Colors
2.17 Mon. 快慢指针 [10/10] 已完成
  • 141. Linked List Cycle
  • 142. Linked List Cycle II
  • 234. Palindrome Linked List
  • 457. Circular Array Loop
  • 918. Maximum Sum Circular Subarray
  • 202. Happy Number
  • 876. Middle of the Linked List
  • 143. Reorder List
  • 287. Find the Duplicate Number
  • 160. Intersection of Two Linked Lists
2.18 Tue. 快慢指针 [10/10] 已完成
  • 206. Reverse Linked List
  • 92. Reverse Linked List II
  • 156. Binary Tree Upside Down
  • 268. Missing Number
  • 41. First Missing Positive
  • 136. Single Number
  • 263. Ugly Number
  • 258. Add Digits
  • 599. Minimum Index Sum of Two Lists
  • 645. Set Mismatch
3.17 Tues. 区间合并 [13] 好难啊啊啊梦魇(update:打败了梦魇)
  • 729. My Calendar I (判断某区间是否与其它区间重合)

  • 731. My Calendar II (判断某区间是否同时与其它k个区间重合)

  • 252. Meeting Rooms I (判断多个区间中是否存在区间重合)

  • 253. Meeting Rooms II (多个区间的重合区间个数)

  • 732. My Calendar III (多个区间的重合区间个数)

  • 56. Merge Intervals 区间合并

  • 57. Insert Interval 区间插入

  • 986. Interval List Intersections 区间交集

  • 435. Non-overlapping Intervals 计算最小删区间个数使不重合

  • 218. The Skyline Problem 区间的附加属性值(e.g.第三维高度)

  • 621. Task Scheduler 最小化区间总长度(...)

  • 207. Course Schedule 判断课程安排是否存在冲突?

  • 636. Exclusive Time of Functions 计算每个区间的无重合长度

[0]
  • [ ]
  • [ ]
  • [ ]
  • [ ]
  • [ ]
  • [ ]
  • [ ]
  • [ ]
  • [ ]
  • [ ]

About

算法的练习日常

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published