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

[其他] 8月刷题/Mock interview接龙活动(缺米刷题的来)

   关闭
🔗
nazo 2020-8-9 06:58:09 | 只看该作者
全局:
刷了三道dp题。日常打卡

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

image.png

评分

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

查看全部评分

回复

使用道具 举报

全局:


report for duty

评分

参与人数 4大米 +4 收起 理由
NeiLGN + 1 加油
zhxy222td + 1 给你点个赞!
LyanW + 1 给你点个赞!
sanmao0715 + 1 赞一个

查看全部评分

回复

使用道具 举报

🔗
sanmao0715 2020-8-9 08:05:23 | 只看该作者
全局:
8.8 打卡三道binary search。index细节太多还需要学习

#34. Find first and last position of element in sorted array
run binary search twice to find lower bound and upper bound
        idx1 = helper(nums, target)
        idx2 = helper(nums, target + 1) - 1
        if idx1 < len(nums) and nums[idx1] == target:
            return [idx1, idx2]
        else:
            return [-1, -1]

The tip for this method is that if target is not in the array, for example in this case, [5,7,7,8,8,10] with target 6 will give us index [1, 0], but since nums[idx1] != target it will output [-1, -1]

Another tricky way:
        double left = target - 0.5, right = target + 0.5;
        int l = bs(nums, left), r = bs(nums, right);
        if(l == r) return new int[]{-1, -1};
        return new int[]{l, r-1};

#33. Search in rotated sorted array
Determine whether mid point is on the left side of the pivot or the right side. Plot the array as a 分段函数。
if nums[low] <= nums[mid]: binary search left
else: binary search right

#81. Search in rotated sorted array II
Mid is a floor of (l+r)/2, so it can be equal to l. We want to make sure that the equal sign in condition nums[i] <= nums[mid] only happens when l = mid, so you have to remove the duplicates for the left.  ex: [3,3,3,3,3,3,4,5,3]
However for the right, it's not necessary, and it can make the calculation slower. For example find 2 in [0, 1, 2, 3, 3, 3, 3, 3, 3, 3], all the 3s can be skipped in a O(logN) manner if you don't do the r -=1, if you do, it will be O(N)

和上面一题同样的分段,但是多了一个dedup的条件:
while l < mid and nums[l] == nums[mid]: # tricky part
            l += 1

评分

参与人数 3大米 +3 收起 理由
huleiming0224 + 1 给你点个赞!
zhxy222td + 1 给你点个赞!
LyanW + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
LyanW 2020-8-9 08:58:10 | 只看该作者
全局:
本帖最后由 LyanW 于 2020-8-9 09:01 编辑
TimLee 发表于 2020-8-7 10:42
今天闹肚子,只打一道题卡
442. Find All Duplicates in an Array

八月day7:
remove element
merge sorted array
duplicate zeros
如果用python的built in function就非常容易,但是感觉还是需要不用function也能写出来
啊不好意思,应该回复主题帖的,按错了

Screen Shot 2020-08-08 at 6.30.03 PM.png (102.81 KB, 下载次数: 0)

Screen Shot 2020-08-08 at 6.30.03 PM.png

评分

参与人数 3大米 +3 收起 理由
MaggieXCJR + 1 给你点个赞!
NeiLGN + 1 加油
zhxy222td + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
zhxy222td 2020-8-9 09:10:45 | 只看该作者
全局:
Take away: 用的dp track 一个string的substring 是 palindrome 还是非palindrome 和对于每一个substring所需要改动的字母数 把他变成一个palindrome 然后用在用一层dp 来minCut 和 min number changes

Screen Shot 2020-08-08 at 6.02.59 PM.png (146.32 KB, 下载次数: 0)

Screen Shot 2020-08-08 at 6.02.59 PM.png

评分

参与人数 3大米 +3 收起 理由
huleiming0224 + 1 给你点个赞!
MaggieXCJR + 1 给你点个赞!
NeiLGN + 1 加油

查看全部评分

回复

使用道具 举报

🔗
NeiLGN 2020-8-9 09:22:41 | 只看该作者
全局:
先上今天的第一题: LeetCode 279 完全平方数

8_8_2020_1.PNG (40.74 KB, 下载次数: 0)

8_8_2020_1.PNG

评分

参与人数 3大米 +3 收起 理由
huleiming0224 + 1 给你点个赞!
McFlurry + 1 欢迎分享你知道的情况,会给更多积分奖励!
MaggieXCJR + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
MaggieXCJR 2020-8-9 09:58:44 | 只看该作者
全局:
今天做了三类题,Kth element, K-way merge, DP Knapsack
DP 的题需要更加深入的理解和练习~

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

image.png

评分

参与人数 3大米 +4 收起 理由
黑犬默默 + 1 给你点个赞!
jollibeeee + 2 很有用的信息!
McFlurry + 1 欢迎分享你知道的情况,会给更多积分奖励!

查看全部评分

回复

使用道具 举报

🔗
miitac 2020-8-9 10:08:04 | 只看该作者
全局:
复习了一下heap的实现 + 打卡两道heap题
heapifyDown的时候要注意左右子元素选最大(maxHeap)/小(minHeap)

Screen Shot 2020-08-08 at 7.04.05 PM.jpg (58.26 KB, 下载次数: 0)

Screen Shot 2020-08-08 at 7.04.05 PM.jpg

评分

参与人数 4大米 +6 收起 理由
lic10 + 2 给你点个赞!
fnwjkm + 1 给你点个赞!
jollibeeee + 2 给你点个赞!
McFlurry + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
McFlurry 2020-8-9 10:14:09 | 只看该作者
全局:
8/8 打卡第三天,今天复习了4道top k的题

评分

参与人数 3大米 +4 收起 理由
黑犬默默 + 1 给你点个赞!
fnwjkm + 1 给你点个赞!
jollibeeee + 2 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
jollibeeee 2020-8-9 10:14:11 | 只看该作者
全局:
8.8 day8 August LeetCoding Challenge

d8.png (44.08 KB, 下载次数: 0)

d8.png

评分

参与人数 3大米 +3 收起 理由
XiangOAJZ + 1 给你点个赞!
黑犬默默 + 1 给你点个赞!
fnwjkm + 1 给你点个赞!

查看全部评分

回复

使用道具 举报

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

本版积分规则

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