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

11月中回国探亲,争取在这之前搞定面试跳槽!

全局:

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

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

x
11月打算回趟国看爸妈,争取之前把跳槽搞定了。回去就想玩了。

今天focus在String. dynamic programming.
  • Word Break
  • Longest Palindrome
  • Regular Expression Matching


看了:
  • XML to tree: Stack to keep pointers  + TreeNode structure.
  • Longest Palindromic subsequence/sequence: dp[s.length()][s.length()] base is index
  • Longest Common substring/sequence: dp[s1.length()+1][s2.length()+1] base is length // seems base is length when involving 2 strings.


明天看完string -> array, focus在sliding window




补充内容 (2021-08-18 12:34 +8:00):
check

上一篇:机械制造在职力扣做题记录(目标每天3题)
下一篇:CS61A 2021求同期一起讨论小组(10月开始)
推荐
 楼主| meng1223 2021-8-29 08:47:55 | 只看该作者
全局:
本帖最后由 meng1223 于 2021-8-28 18:43 编辑

More on concurrency design:
- .wait() put thread in wait, need to call notify() / notifyall()
- thread.sleep(). Is not the same as wait(). does not release the lock.
- join(): thread t(usually main thread) calling join on t1, then t wait till t1 dead. does not affect t2.
- concurrency vs parallism
- mutex vs semaphore, busy wait solution.
- object monitor
synchronize on the object, not the object.method()


补充内容 (2021-08-29 09:50 +8:00):
synchronize -> 1 thread a time.
semaphore can alow multiple access.

补充内容 (2021-08-29 09:54 +8:00):
no concept of ownership for sempahore

补充内容 (2021-08-29 09:57 +8:00):
producer/consumer application -> signal on using semaphore. p1 call s.acquire() and add stuff, c1.release() before consume

补充内容 (2021-08-29 10:07 +8:00):
using two sempahore (1 consumeSemaphore 1 producerSemaphore to acheive multiple access.)

补充内容 (2021-08-29 12:01 +8:00):
Graph:
- linkedlist to represent graph, memory efficient
- dfs for finding cycle in directed graph. bfs cannot.
回复

使用道具 举报

推荐
 楼主| meng1223 2021-8-25 13:50:26 | 只看该作者
全局:
Finish sorting topic
75. Sort Colors
// merge sort
// in place three pointers, only update curr when swap(curr, left) and num[curr]==1.


takeaway:
- modified binary search, can be implemented recursively.
- worst case quick sort: 1) descending or 2) duplicates and pivot choosen is always the first element
- reduce swap -> selection sort


回复

使用道具 举报

推荐
 楼主| meng1223 2021-8-17 14:00:55 | 只看该作者
全局:
做了两道sliding window:
904. Fruit Into Baskets
340. Longest Substring with At Most K Distinct Characters // takeaway: use hashmap instead of set. Removal needs to track the frequency.

// sliding window is part of dp.
https://medium.com/outco/how-to- ... roblems-28d67601a66
https://medium.com/outco/the-alg ... orithm-28043fe47b51
回复

使用道具 举报

🔗
 楼主| meng1223 2021-8-18 12:34:18 | 只看该作者
全局:
本帖最后由 meng1223 于 2021-8-17 21:36 编辑

还是string: (permutations)

784. Letter Case Permutation // continue, break only works for innter loop.  BFS
https://medium.com/outco/the-alg ... orithm-28043fe47b51 写的挺好,花时间看完了。
回复

使用道具 举报

🔗
 楼主| meng1223 2021-8-19 13:11:40 | 只看该作者
全局:
复习了一下sorting
O(n^2)
- selection sort
- bubble sort
- insertion sort

O(NlogN)
- merge sort: (height logN * N operations per level)

刷题:
20, 24 - permutations
回复

使用道具 举报

🔗
 楼主| meng1223 2021-8-23 13:17:39 | 只看该作者
全局:
最近几天没更新。。。

74. Search a 2D Matrix
442. Find All Duplicates in an Array  // negate the element at index
4. Median of Two Sorted Arrays // hard, (m + n + 1 )/ 2 && (m+n+2)/2
Usually search -> O(logN) -> binary search for sorted array

补充内容 (2021-08-23 14:31 +8:00):
34. Find First and Last Position of Element in Sorted Array // variation of binary search, instead of == target, adding more conditions. binary search -> recursion .
回复

使用道具 举报

🔗
 楼主| meng1223 2021-8-26 13:02:13 | 只看该作者
全局:
Greedy algorithm
1167. Minimum Cost to Connect Sticks
not so greedy: 322. Coin Change -> dp
回复

使用道具 举报

🔗
 楼主| meng1223 2021-8-27 12:44:18 | 只看该作者
全局:
Divide & Conquer

53. Maximum Subarray
// two way:
1. dp: always keep when sum > 0, otherwise  start from num > 0
2. divide + conqure. find left, find right, find combined (combined must include middle)


162. Find Peak Element
//binary search -> recursion, find peak by pruning the slope.


补充内容 (2021-08-27 14:27 +8:00):
multithread, join(), run(), start(), runnable interface.
回复

使用道具 举报

🔗
 楼主| meng1223 2021-8-30 07:40:32 | 只看该作者
全局:
More on thread design:

Rate limiting using token bucket:
1. time pointer: check if current - lastRequire > 1 sec
2. daemonthread, sleep for 1 sec, then wake up and add token, notify other thread.
- problem: never start a thread in constructor, as child thread might use unconstructed object.
- solve: using factory pattern.

==============


补充内容 (2021-08-30 11:55 +8:00):
OOD:
creational pattern:
- builder
- singleton
- prototype (clone) // similar to factory method
- factory method
- abstract factory


static simple factory is not a factory pattern.  -> cannot extend.
回复

使用道具 举报

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

本版积分规则

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