当前位置:网站首页>leetcode:300. Longest increasing subsequence [LIS board + greedy dichotomy + nlogn]
leetcode:300. Longest increasing subsequence [LIS board + greedy dichotomy + nlogn]
2022-07-18 03:30:00 【White speed Dragon King's review】

analysis
Greedy thoughts : One at a time , Make his rise as small as possible
Maintain an incremental ans, If it's bigger than the last one, join
Otherwise, insert it into the appropriate position , Replace the last one ( Reduce the rise )
ac code
class Solution:
def lengthOfLIS(self, nums: List[int]) -> int:
ans = [] # keep increasing
for num in nums:
if not ans or ans[-1] < num:
ans.append(num)
else:
# replace, equal also replace
idx = bisect_left(ans, num)
ans[idx] = num
return len(ans)
summary
LIS The board + Greedy dichotomy
边栏推荐
- leetcode:558. 四叉树交集【四叉树dfs】
- Will the expired data of redis be deleted immediately? Great mystery
- 在线办公,如何让协同更高效?
- 麦肯锡:未来十年,十大顶尖技术趋势将影响投资和研究方向
- Once, I sprayed AI customer service for two minutes, and it only replied to my first sentence
- 线程-interrupt方法详解
- TiKV & TiFlash 加速复杂业务查询
- Devkit mpc5744p configuring RTOS
- Two years ago, how were the leading players and blue chips in defi?
- LNMP architecture PHP installation
猜你喜欢
随机推荐
Talk about seven ways to realize asynchronous programming
Issue 100: encapsulate the flitter component of short answer
Cloud challenge of home decoration industry software
DataArts Studio数据架构——基于模型驱动的智能自动化流水线建设案例
Euler talk | developer community experience bureau starts at about 19:30 on July 14
lnmp架构php安装
騰訊大咖分享 | 騰訊Alluxio(DOP)在金融場景的落地與優化實踐
[MySQL] multi table query
Musk suspends twitter acquisition, with a breakup fee of $1billion
盖茨再捐200亿美元,谷歌云转投ARM,推特员工因马斯克遭CEO警告,今日更多大新闻在此...
After 00, he graduated from Nanjing University and planned to be a special associate researcher. Netizens quarreled after picking out their papers
[Xingguang 04] 2022 deep learning GPU form
Infrared remote control atmosphere lamp touch chip-dlt8sa15a-jericho
Issue 89: Simple Thoughts on Pinia
File parsing_ Excel file parsing
Configure @ in vite to access files under Src
解析协同办公“协同”为何意,数字化办公又如何轻松“破题”?
Website vulnerability repair service providers explain the reasons for ultra vires vulnerabilities
在线办公,如何让协同更高效?
数据传输:同构异IP数据源批量抽取实践









