123
返回列表 发新帖
楼主: sly--
跳转到指定楼层
上一主题 下一主题
收起左侧

刷题打卡贴

🔗
 楼主| sly-- 2020-1-10 14:07:51 | 只看该作者
全局:
python 191. Number of 1 Bits
use & can just count the number of 1's
70. Climbing Stairs
so if we know the previous steps, we can 2 steps

sql 569. Median Employee Salary
when u wanna find the median if they have multiple same value then this number of the same value is the difference between value larger than this value and value smaller than this value which can be solved by sign()
回复

使用道具 举报

🔗
 楼主| sly-- 2020-1-12 13:15:21 | 只看该作者
全局:
python 53. maximum subarray
for this question, I would like to use dynamic programming. We wanna find the global maximum, not the local one, so we need a variable to keep the value of the global maximum. And for all the values in the array, we can set that if the previous sum is negative, we will only keep the current value. Then we should keep variable prev and variable curr. We should set the initiate global maximum if float('-inf'), so if the value in array was negative, we could still get the curr value.
101. Symmetric Tree
For this question, we would know if this is a symmetric tree, the value of root should be equal and the left leaf of t1 should be as same as the right leaf of t2. Then the right leaf of t1 should be as well as the left leaf of t2.
1. two sum
For this question, we get to know it will have exactly one answer and numbers cannot be used twice.  We can use hash map to reduce the big o time. We can assume if the compensate number is in dic then we just return the compensate number's idx and the curr value's idx, if not we can add the curr val in the dic.
回复

使用道具 举报

🔗
 楼主| sly-- 2020-1-15 03:53:12 | 只看该作者
全局:
python 26. Remove Duplicates from Sorted Array
This is a sorted array, so we just compare the sequence.

326. Power of Three

SQL 618. Students Report By Geography
pivot table, could use the same number of variable in case when when clause to set as the one rowline and then group by rowline .
回复

使用道具 举报

🔗
 楼主| sly-- 2020-1-18 04:58:54 | 只看该作者
全局:
python 66. Plus One '''add one to the last value of array
        There are two situations. One is the last value smaller than 9, so we can just add one to this value. Another one is the last value is 9 if we add one to that, we should consider carry the one to higher digit'''

155. Min Stack
for this question, u have to keep a min keeper in the stack, so that we can get constant time for getMin().
20. Valid Parentheses
回复

使用道具 举报

🔗
 楼主| sly-- 2020-1-18 06:50:15 | 只看该作者
全局:
sql 571. Find Median Given Frequency of Numbers
SELECT sum(distinct n.number)/count(distinct n.number) as median
FROM numbers n
WHERE n.frequency >= (select abs(sum(sign(n1.number - n.number)*n1.frequency))
                    from numbers n1)
回复

使用道具 举报

🔗
 楼主| sly-- 2020-1-29 03:21:25 | 只看该作者
全局:
sql 1322. Ads Performance
ifnull()
回复

使用道具 举报

🔗
 楼主| sly-- 2020-1-29 04:21:57 | 只看该作者
全局:
python 172. Factorial Trailing Zeroes
回复

使用道具 举报

🔗
 楼主| sly-- 2020-2-11 01:39:59 | 只看该作者
全局:
sql 1321. Restaurant Growth
need to narrow down that the condition of distinct previous visited_on is larger than 6
回复

使用道具 举报

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

本版积分规则

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