查看: 5047| 回复: 19
跳转到指定楼层
上一主题 下一主题
收起左侧

[Leetcode] 时隔两年,我又来刷题面狗家了

全局:

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
上周刚被狗家recruiter撩,约上了1/12的店面(之前ng时候走到过onsite,这次居然不能skip,好吧)


补充内容 (2022-01-01 05:20 +8:00):
买了利口premium,计划直接按照Google tag的频率开始刷,每天4题吧

补充内容 (2022-01-24 14:54 +8:00):
店面直接被鸽。。不过recruiter神奇说道直接帮我skip店面,约上了2月18的昂赛。。

评分

参与人数 2大米 +2 收起 理由
rachaelsun + 1 赞一个!
14417335 + 1 给你点个赞!

查看全部评分


上一篇:请问普通数学乘法&除法在python里时间复杂度多少?比如 a*b, a/b 这种回复加米!!
下一篇:Leetcode 刷题Java讲解视频
全局:
楼主快别这里打卡了,万一面你的国人看到了,就不出你刷的题,可惜了。
回复

使用道具 举报

全局:
别用英文吧。。

评分

参与人数 2大米 +2 收起 理由
sleepysandy + 1 赞一个
家有5电视 + 1 赞一个

查看全部评分

回复

使用道具 举报

推荐
 楼主| easyham 2022-1-12 02:54:28 | 只看该作者
全局:
Monday 1/10

- Random Pick with Weight: construct prefix sum array, then randomly pick a number between (start, end), use binary search to find the interval

- Evaluate Reverse Polish Notation: stack

- Maximum Points You Can Obtain from Cards: construct prefix sum and suffix sum, then iterate through all combination from left k right 0 to left 0 right k, to find out which one has the highest number

- Number of Boomerangs: construct dist difference hashmap, store frequency, at the end, if frequency >= 2, the combination logic could be n!

- Decode String:
upon seeing a ']', pop stack until seeing a '[', then pop, then pop digit, read digit as binary, then push push str list reversely into stack again

- New 21 Game: probability game, observe that "n or few points" means p[n] + p[n-1] +...+p[1], construct a dp array, sum them up by 1/maxPts

- Split Array Into Consecutive Subsequences:  fundamentally, this problem is about making decision between for each point, whether insert into an existing tuples, or create a new one, and since the order has already been sorted, if you have to create a new one, and previous ones don't reach 3, that means false.

评分

参与人数 1大米 +1 收起 理由
rachaelsun + 1 赞一个

查看全部评分

回复

使用道具 举报

🔗
 楼主| easyham 2021-12-28 16:05:58 | 只看该作者
全局:
Monday 12/27

- Find Leaves of Binary Tree: the key is to leverage height() algorithm to find each leaf's height, store into pair, and then sort the pair to collection the answer.

- Guess the Word: each time call the guess API, return the answer, then compare all existing strs, remove all strings that is not x chars different than the current word.

- Shortest Path in a Grid with Obstacles Elimination: use BFS to guarantee finding the shortest path, use elimination of obstacles as much as you can, because if you make to the end it must be the shortest path.

- Maximum Number of Points with Cost: DP solution - 2D array with i represents the row, and j represents if I select point[i][j], what would be my maximum gain.
回复

使用道具 举报

🔗
rachaelsun 2021-12-28 16:13:38 | 只看该作者
全局:
给小哥哥加油打气

评分

参与人数 1大米 +1 收起 理由
easyham + 1 赞一个

查看全部评分

回复

使用道具 举报

🔗
 楼主| easyham 2021-12-28 16:16:40 来自APP | 只看该作者
全局:
我家宝贝来看我啦,YAY
回复

使用道具 举报

🔗
 楼主| easyham 2021-12-30 06:56:55 | 只看该作者
全局:
Tuesday 12/28

- Snapshot Array: use HashMap to store key: index, value: snap_id, upon searching, starting from the latest snap_id, backtrace until find a one with snap_id, return the value.

- Asteroid Collision: push positive val into stack, upon seeing negative, pop

- Find Original Array From Doubled Array: sort first, then use set to compare

- Logger Rate Limiter: ?? Too easy.. one time pass

评分

参与人数 1大米 +1 收起 理由
rachaelsun + 1 赞一个

查看全部评分

回复

使用道具 举报

🔗
flattop2016 2021-12-30 08:37:07 | 只看该作者
全局:
是分天VO 的?赞楼主的分享
回复

使用道具 举报

🔗
 楼主| easyham 2022-1-1 04:08:52 | 只看该作者
全局:
Wednesday 12/29

- FInd And Replace in String: construct a new obj Data, associate indices, sources and targets into the array, leverage the "startWith" method in String API

- Longest String Chain: DFS from the last word, keep deleting one char at a single time, use StringBuilder to perform deleteCharAt, use Set to avoid duplication, use Map to memoize (dynamic programming) to remember certain branches max outcome.

- Number of Matching Subsequences: two pointers

- Number of Islands:
1. recursively DFS O(m*n)
2. iteratively BFS, for each grid, construct a queue<Pair<Row, Col>>, *note: do the preprocess before
3. union find: construct two arrays, one for parent index, one for its corresponding rank, then iterate through all the grids, upon seeing "1", perform union from all the four dimensions, at the end, return getCount(), which is the number of disjoint sets.  O(m * n);
回复

使用道具 举报

🔗
 楼主| easyham 2022-1-1 05:06:16 | 只看该作者
全局:
easyham 发表于 2021-12-31 12:08
Wednesday 12/29

- FInd And Replace in String: construct a new obj Data, associate indices, source ...

Follow up:
- Redundant Connection: very good practice for union find.
回复

使用道具 举报

🔗
 楼主| easyham 2022-1-1 10:00:03 | 只看该作者
全局:
Friday 12/31
- Minimum Difference Between Largest and Smallest Value in Three Moves: fundamentally, it's a circular sliding window problem, for n moves, you have n possibilities, use mod to enumerate overflow indices. and Math.min to compare each scenarios
回复

使用道具 举报

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

本版积分规则

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