楼主: xxcindy
跳转到指定楼层
上一主题 下一主题
收起左侧

定个小目标,刷个300题

🔗
 楼主| xxcindy 2021-3-28 11:40:32 | 只看该作者
全局:
Day 10: 2021-03-27

[51] N-Queens - H
[52] N-Queens II - H

- Since we can only put one Q in one row, so we go thru row by row (loop 1)
- In each row, we go through each cell (potential solution) (loop 2)
- For each cell, check if that cell is valid
- If valid, place Q and continue on the next row (loop 1)
- If not valid, remove Q
- Terminate, if row === n, add the local solution to the results

How to test if it is valid:
- colTaken
- daleTaken (\ diagonal): row + col = constant
- hillTaken (/ diagonal): row - col = constant

Num of Q solved 94 -> 96

Repo: https://github.com/xindixu/leetc ... 8fa1c5175cf8f46c3ce
回复

使用道具 举报

🔗
 楼主| xxcindy 2021-3-29 12:56:06 | 只看该作者
全局:
Day 11: 2021-03-28

Review day

[89] Gray Code - M
[93] Restore IP Addresses - M
[36] Valid Sudoku - M
[37] Sudoku Solver - H
[51] N-Queens - H
[52] N-Queens II - H

Num of Q Reviewed: 6
回复

使用道具 举报

🔗
 楼主| xxcindy 2021-4-1 11:38:09 | 只看该作者
全局:
补一下:
Day 12: 2021-03-29
没刷题。在做公开课的project
回复

使用道具 举报

🔗
 楼主| xxcindy 2021-4-1 11:39:26 | 只看该作者
全局:
补一下:
Day 13: 2021-03-30
刷了一题。在做公开课的project

[80] Remove Duplicates from Sorted Array II - M

Num of Q solved: 96 -> 97
回复

使用道具 举报

🔗
 楼主| xxcindy 2021-4-1 11:41:14 | 只看该作者
全局:
Day 14: 2021-03-31

[33] Search in Rotated Sorted Array - M
[69] Sqrt(x) - E
[34] Find First and Last Position of Element in Sorted Array - M
[81] Search in Rotated Sorted Array II - M

主要focus在binary search
Num of Q solved: 99
Repo: https://github.com/xindixu/leetc ... 839bc7284055cac8048
回复

使用道具 举报

🔗
 楼主| xxcindy 2021-4-2 12:58:33 | 只看该作者
全局:
Day 15: 2021-04-01

[50] Pow(x, n) - M
simple recursion
[162] Find Peak Element - M
binary search, using slope
[209] Minimum Size Subarray Sum - M
two pointers

Num of Q solved: 99 -> 102
Repo: https://github.com/xindixu/leetc ... 692586f171ac4b49b02
回复

使用道具 举报

🔗
 楼主| xxcindy 2021-4-3 12:41:17 | 只看该作者
全局:
Day 16: 2021-04-02

[240] Search a 2D Matrix II - M
Start with the top right corner. R always increment, C always decrement. If cur is too small, increment R. If cur is too big, decrement C.

[387] First Unique Character in a String - E
hash table, loop through it twice

[120] Triangle
DP, reuse original array

[287] Find the Duplicate Number
LinkedList,
index 0 1 5
value 1 5 7
1 -> 5 -> 7
Use index & value to create a linked list. Use tortoise - hare cycle detection to find the entrance of the cycle, which is the duplicated item.
It is the duplicated item because there are multiple indices pointing to that value

Num of Q solved: 102 -> 106
Repo: https://github.com/xindixu/leetc ... 1ca65b520b6693cdef2
回复

使用道具 举报

🔗
 楼主| xxcindy 2021-4-6 12:54:52 | 只看该作者
全局:
Day 17: 2021-04-03
Day 18: 2021-04-04偷懒

Day 18: 2021-04-05

[4] Median of Two Sorted Arrays  - H
想清楚median的definition: a point that divides the array into two halves AND the elements in the left half is smaller than the elements in the right half.

Num of Q solved: 106 -> 107
又是一晚上做一题 好难啊。不过这道题的解法很有意思。

Repo: https://github.com/xindixu/leetc ... eda368bfe407f8e5d6e
回复

使用道具 举报

🔗
 楼主| xxcindy 2021-4-7 12:58:53 | 只看该作者
全局:
Day 19: 2021-04-06

[349] Intersection of Two Arrays - E
[350] Intersection of Two Arrays II - E
[174] Dungeon Game - H
2d DP. Start with what we know -> bottom-right corner
[217] Contains Duplicate - E
[219] Contains Duplicate II

Num of Q solved: 107 -> 112
回复

使用道具 举报

🔗
 楼主| xxcindy 2021-4-9 08:16:04 | 只看该作者
全局:
Day 20: 2021-04-07

Review Day:
[80] Remove Duplicates from Sorted Array II - M
[33] Search in Rotated Sorted Array - M

不会的还是不会,不过稍微看看提示就可以过了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表