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

刷题记录帖子

🔗
 楼主| Myron2017 2021-5-19 05:03:25 | 只看该作者
全局:
609. Find Duplicate File in System

感觉这道题目的 follow up 特别有意思。

BFS vs DFS
BFS explores neighbors first. This means that files which are located close to each other are also accessed one after another. This is great for space locality and that's why BFS is expected to be faster. Also, BFS is easier to parallelize (more fine-grained locking). DFS will require a lock on the root node.

Very large files and false positives
For very large files we should do the following comparisons in this order:

compare sizes, if not equal, then files are different and stop here!
hash them with a fast algorithm e.g. MD5 or use SHA256 (no collisions found yet), if not equal then stop here!
compare byte by byte to avoid false positives due to collisions.
Have you used an IDE in remote development mode?
For example, CLion has some options on how to compare the local files with the remote server files and then decides to synchronize or not.

Complexity
Runtime - Worst case (which is very unlikely to happen): O(N^2 * L) where L is the size of the maximum bytes that need to be compared
Space - Worst case: all files are hashed and inserted in the hashmap, so O(H^2*L), H is the hash code size and L is the filename size
回复

使用道具 举报

🔗
 楼主| Myron2017 2021-5-20 12:39:54 | 只看该作者
全局:
453. Minimum Moves to Equal Array Elements

len*(min+k)=sum+k*(len-1). ==> k=sum-min*len
回复

使用道具 举报

🔗
 楼主| Myron2017 2021-5-20 12:40:25 | 只看该作者
全局:
462. Minimum Moves to Equal Array Elements II

This problem is deceptive in its simplicity. Ultimately, the value to which you want to set each element equal is the median of the sorted nums array. To come to this realization, we have to first think about the nature of the problem.

Let's consider a possible scenario in which we've decided that our target value is x which would take ans number of moves to complete. What would happen to ans if we increased x by 1? If we did, each element that is below the new x would have to spend another move to get up to x, but every element that is above the new x would have to spend one less move to get down to x.

This means that x should naturally move up if there are more elements above x than below. It also means the inverse, that x should move down if there are more elements below x than above. The natural outcome of this is that x will settle at a spot where there are the same number of elements on either side, which is the median value of nums.

https://leetcode.com/problems/mi ... ution-w-Explanation
回复

使用道具 举报

🔗
 楼主| Myron2017 2021-5-21 03:42:58 | 只看该作者
全局:
102. Binary Tree Level Order Traversal

之前写过,这次 3 min 解决,给自己加个油,功不唐捐。
回复

使用道具 举报

🔗
 楼主| Myron2017 2021-5-22 11:26:46 | 只看该作者
全局:
890        Find and Replace Pattern        Medium        5        Two Maps CrossCheck / One Map FingerPrint
回复

使用道具 举报

🔗
 楼主| Myron2017 2021-5-25 01:48:06 | 只看该作者
全局:
485        Max Consecutive Ones

Easy 但是需要知道如何简洁地得到 code。

回复

使用道具 举报

🔗
 楼主| Myron2017 2021-5-25 02:46:39 | 只看该作者
全局:
                               
414        Third Maximum Number        Easy        4        set, sort, a[-3] for third max
回复

使用道具 举报

🔗
 楼主| Myron2017 2021-5-25 02:58:27 | 只看该作者
全局:
263        Ugly Number        Easy        3        Definiation of ugly number
回复

使用道具 举报

🔗
 楼主| Myron2017 2021-5-25 04:17:18 | 只看该作者
全局:
LC 197

SQL to remember how to do



  1. # Write your MySQL query statement below
  2. SELECT
  3.     weather.id AS 'id'
  4. FROM
  5.     weather
  6.         JOIN
  7.     weather w ON DATEDIFF(weather.recordDate, w.recordDate) = 1
  8.         AND weather.Temperature > w.Temperature
  9. ;

复制代码
回复

使用道具 举报

🔗
 楼主| Myron2017 2021-5-25 04:34:29 | 只看该作者
全局:
118        Pascal's Triangle        Easy
回复

使用道具 举报

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

本版积分规则

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