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

新人刷题打卡贴

全局:

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

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

x
已经刷了1个多月了才发现这里
发个打卡贴求大米

之前刷了200+题
现在再按花花酱的分类刷,觉得很不错:https://bit.ly/2E8yBHq

评分

参与人数 3大米 +4 收起 理由
yanliangwu + 1 赞一个
zmycqw + 2 给你点个赞!
tkwang0530 + 1 赞一个

查看全部评分


上一篇:19fall,phd/master混申,刷题求队友 一起进步
下一篇:51次solved开始
推荐
 楼主| fuxi9999 2019-3-16 12:55:23 | 只看该作者
全局:
贴一个Binary index tree vs Segment tree的讲解
source: https://www.quora.com/How-does-o ... ree-or-Fenwick-Tree

Here are the things to keep in mind while deciding whether to use segment tree or binary indexed tree:
Anything that can be done using a BIT can also be done using a segment tree : BIT stores cumulative quantities for certain intervals. Segment tree stores cumulative quantities for those intervals and more. In particular, if we are creating a data structure to deal with an array of size N=2^K, the BIT will have cumulative quantities for N intervals whereas the segment tree will have cumulative values for 2N-1 intervals
There are things that a segment tree can do but a BIT cannot : A BIT essentially works with cumulative quantities. When the cumulative quantity for interval [i..j] is required, it is found as the difference between cumulative quantities for [1...j] and [1...i-1]. This works only because addition has an inverse operation. You cannot do this if the operation is non-invertible (such as max). On the other hand, every interval on a segment tree can be found as union of disjoint intervals and no inverse operation is required
A BIT requires only half as much memory as a segment tree : In cases where you have masochistic memory constraints, you are almost stuck with using a BIT
Though BIT and segment tree operations are both O(log(n)), the segment tree operations have a larger constant factor : This should not matter for most cases. But once again, if you have masochistic time constraints, you might want to switch from a segment tree to a BIT. The constant factor might become more of a problem if the BIT/Segment tree is multidimensional.
With practice, coding either will be very fast : If you have coded a segment tree 100 times, you will get it very fast the next time you do it. So no need to worry about code being long.

Personally, I invariably use segment trees to solve competitive programming problems. I have probably used BITs only 2-3 times in my entire life, and that was only because some sadist set problems with too tight time/memory constraints.

补充内容 (2019-3-16 12:56):
格式都没了,不好读的话可以去看原文
回复

使用道具 举报

推荐
 楼主| fuxi9999 2019-3-10 10:58:59 | 只看该作者
全局:
今天主要在看Kth largest/smallest
215. Kth Largest Element in an Array / 378. Kth Smallest Element in a Sorted Matrix / 668. Kth Smallest Number in Multiplication Table / 703. Kth Largest Element in a Stream
•        215. Brute Force – Sort:  Time: O(NlogN), Space: O(1)
•        215. Min Heap: keep K element min heap - Time: O(NlogK) / O(K+(N-K)logK), Space: O(K)
•        215. Max Heap: Build N element max heap, and pop K elements - O(N+KlogN), Space: O(N)
•        215. Quickselect: pivot and partition the array O(N)
o        Worst case O(N2), but can be resolved by randomization
•        Generally, use min heap for Kth largest. Keep K element in heap, then root is the answer.


补充内容 (2019-3-10 11:48):
378,668 Binary search 的performance 都会比heap 好
回复

使用道具 举报

推荐
 楼主| fuxi9999 2019-4-6 11:59:19 | 只看该作者
全局:
这周末打算做个challenge, 把这两门课的slides给过一遍
https://www.cs.princeton.edu/~rs/AlgsDS07/
https://web.stanford.edu/~ouster ... ring19/lectures.php
也欢迎大家推荐自己觉得比较好的课程
回复

使用道具 举报

🔗
 楼主| fuxi9999 2019-3-11 07:48:37 | 只看该作者
全局:
今天主要看BST
BST主要是inorder traversal, binary search, add/delete node

花花酱列表里的题:LC 98,530,700,701,230,99,108,501,450

补充内容 (2019-3-11 13:10):
晚上看了hashtable
2sum, 4sum, 560
回复

使用道具 举报

🔗
 楼主| fuxi9999 2019-3-12 12:54:22 | 只看该作者
全局:
今天时间不多
看了狗家的2道面筋
1. battleship
2. snapshot array
回复

使用道具 举报

🔗
esthertseng 2019-3-13 01:00:59 | 只看该作者
全局:
持續努力一起加油

评分

参与人数 1大米 +1 收起 理由
fuxi9999 + 1 谢谢

查看全部评分

回复

使用道具 举报

🔗
 楼主| fuxi9999 2019-3-13 12:43:47 | 只看该作者
全局:
今天刷了下linked list
2,445,24,206,141,142,21,23,147,148,707

linked list很多时候用一个slow,一个fast pointer找中点
回复

使用道具 举报

🔗
 楼主| fuxi9999 2019-3-14 10:37:06 | 只看该作者
全局:
先看了two pointer
11, 167, 977
回复

使用道具 举报

🔗
 楼主| fuxi9999 2019-3-15 13:19:16 | 只看该作者
全局:
Recursion
726,736,856
回复

使用道具 举报

🔗
 楼主| fuxi9999 2019-3-16 12:03:31 | 只看该作者
全局:
315 - BST and BIT
主要学习了binary index tree
回复

使用道具 举报

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

本版积分规则

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