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

刷题记录帖子

🔗
 楼主| 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
回复

使用道具 举报

🔗
 楼主| Myron2017 2021-5-26 06:51:19 | 只看该作者
全局:
本帖最后由 Myron2017 于 2021-5-26 06:52 编辑

LeetCode 150. Evaluate Reverse Polish Notation (Python)

原理理解了,这里好多 Python 的细节考察啊!~
How to round to Zero + How to get Python string a number either postive or negative



回复

使用道具 举报

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

本版积分规则

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