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

[其他] 7月缺米的来刷题/Mock interview活动

   
全局:
day 2:
1. Binary Tree Maximum Path Sum 第一次提交出错时因为,把一开始的global max 设置成了0, 就fail in case [-3]
2. Longest Continuous Increasing Subsequence, easy
3. Longest Increasing Subsequence, used dp to solve it in o(n square). surprised to see the solution of using DP + binary search, is it a requirement now?

Screen Shot 2020-07-10 at 12.23.32 AM.png (59.35 KB, 下载次数: 0)

Screen Shot 2020-07-10 at 12.23.32 AM.png

评分

参与人数 3大米 +3 收起 理由
Jiangbi + 1 给你点个赞!
szzxmf + 1 给你点个赞!
DL + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
zouying594 2020-7-10 12:29:44 | 只看该作者
全局:
Day 4:
Closest Binary Search Tree Value, using res to store result, if target > val, go right, else go left.
Nested List Weight Sum, dfs or bfs
Expression Add Operators, dfs, need to store the previous tem result for multicplication.
Group Shifted Strings,using the gap(to_string) as key to group the strings.
Maximum Swap ,greedy,1st loop, remember last pos of char, 2 loop, from big number 9 to current number, found then swap.
Random Pick Index, reservoir sampling, find the first position that number equals to target , cnt ++ , if rand()%cnt == 0, swap the i to ans.  

image.png (49.35 KB, 下载次数: 0)

image.png

评分

参与人数 4大米 +4 收起 理由
xiaocaicai + 1 给你点个赞!
Jiangbi + 1 给你点个赞!
szzxmf + 1 给你点个赞!
DL + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
DL 2020-7-10 12:31:57 | 只看该作者
全局:
7/9 打卡第9天, 刷了3道题

125. Valid Palindrome
先去掉不是数字和字母的字符

167. Two Sum II - Input array is sorted
双指针

169. Majority Element
hashing。 另一个不用hashing的方法,用count计数, 每次count突破0时,记下当前的majority,每出现一次,count++,否则count--。

image.png (99.19 KB, 下载次数: 0)

image.png

评分

参与人数 4大米 +4 收起 理由
dtmntion + 1 给你点个赞!
xiaocaicai + 1 给你点个赞!
Jiangbi + 1 给你点个赞!
szzxmf + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

全局:
干活忙,还要帮个人顶,想做点简单的
然后么,简单array的题目,基本是脑筋急转弯,大部分和算法没关系
day 3还是4啊

image.png (71.92 KB, 下载次数: 0)

image.png

评分

参与人数 3大米 +3 收起 理由
dtmntion + 1 给你点个赞!
xiaocaicai + 1 给你点个赞!
Jiangbi + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
dtmntion 2020-7-10 12:49:21 | 只看该作者
全局:
本帖最后由 dtmntion 于 2020-7-10 12:52 编辑

今日三题, Array系列,比较简单

Screen Shot 2020-07-09 at 9.48.19 PM.png (78.88 KB, 下载次数: 0)

Screen Shot 2020-07-09 at 9.48.19 PM.png

评分

参与人数 1大米 +1 收起 理由
dsnadja + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
Jiangbi 2020-7-10 12:50:43 | 只看该作者
全局:
七月第十天!
1. maximum width of binary tree: 可以用dfs,每次存每一层最左边的index,一般node index是i的话children就是2i和2i+1,
    然后每层的width就是最右边index减掉最左边的index,每次取最大值再看children的recursive function
2. valid parenthesis string: 可以用greedy来做,每次记opening bracket数量的upper bound和lower bound,如果确定是(的话
    就把lower bound加一,不是)的话就说明有可能可以记作(,把upper bound加一,最后看lower是不是等于0
3. longest common subsequence: 可以用dp[i][j]来存到string1[i] 和string2[j]的最长common subsequence, 如果两个string在i,j
    相等,dp[i+1][j+1] = dp[i][j] + 1, 不然的话dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j])
4. backspace string compare: 这个可以用two pointer 从后向前,每次记可以skip的个数,可以分别把backspace skip完了再比较
5. longest palindromic subsequence: dp[i][j]存i, j substring中的最长subsequence,dp[i][i] = 1, 如果i,j的char相等,dp[i][j] =
    dp[i+1][j-1]+2, 不然的话dp[i][j] = max(dp[i+1][j], dp[i][j-1])


submissions.PNG (38.19 KB, 下载次数: 0)

submissions.PNG

评分

参与人数 2大米 +2 收起 理由
JLSeagull + 1 给你点个赞!
dtmntion + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
xiaocaicai 2020-7-10 12:51:08 | 只看该作者
全局:
打卡第四天
1.Exclusive Time of Functions 用模拟单线程cpu 关键在于用stack模拟停止函数运行
2.Candy Crush 标准的grid搜索问题
3. Find Duplicate File in System 标准的hashmap问题 string.split()的应用
3道中等难度题 贵在坚持!

image.png (103.57 KB, 下载次数: 0)

image.png

评分

参与人数 2大米 +2 收起 理由
zry1993 + 1 给你点个赞!
JLSeagull + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
fshan 2020-7-10 12:53:56 | 只看该作者
全局:
今天刷的有点磕磕绊绊,动态规划要集中总结一下才行

image.png (143.04 KB, 下载次数: 0)

image.png

评分

参与人数 3大米 +3 收起 理由
fnwjkm + 1 给你点个赞!
zry1993 + 1 给你点个赞!
JLSeagull + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
JLSeagull 2020-7-10 13:09:10 | 只看该作者
全局:
07/09 三题

最佳买卖股票时机含冷冻期
买卖股票系列 可以转化为持有和卖出 然后利用动态规划实现
4的幂 转换成二进制 利用4的幂一定是2的幂判断
1比特与2比特字符 遍历碰到1跳过一个

评分

参与人数 2大米 +2 收起 理由
fnwjkm + 1 给你点个赞!
zry1993 + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
zry1993 2020-7-10 13:30:02 | 只看该作者
全局:
7.9刷题第三天,三道很简单的题目写了好久。一定是因为自己太浮躁。

Screen Shot 2020-07-10 at 1.27.45 AM.png (75.35 KB, 下载次数: 0)

Screen Shot 2020-07-10 at 1.27.45 AM.png

评分

参与人数 3大米 +3 收起 理由
JLSeagull + 1 给你点个赞!
lanlanblue11 + 1 给你点个赞!
fnwjkm + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

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

本版积分规则

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