Leetcode hard一句话题解

代码:https://github.com/dezhonger/LeetCode

 

99. Recover Binary Search Tree  Morris-traversal算法

218: The Skyline Problem 扫描线算法 

297. Serialize and Deserialize Binary Tree dfs

335. Self Crossing 分类讨论总结规律

381. Insert Delete GetRandom O(1) - Duplicates allowed 数组和哈希表,删除通过和最后一个交换做到O(1)

407. Trapping Rain Water II 二维雨水问题,堆

432. All O`one Data Structure 双向链表+哈希表

440. K-th Smallest in Lexicographical Order 按位考虑,逐位确定前缀

460. LFU Cache 双向链表套双向链表,外层的双向链表维护所有访问频率为cnt的节点,每个双向链表维护一串node,按照访问时间的顺序,最头部为访问最近的节点

466. Count The Repetitions 找循环节

488. Zuma Game 搜索/启发式搜索

502. IPO 贪心,堆

514. Freedom Trail dp

564. Find the Closest Palindrome 枚举左半边以及边界情况

675. Cut Off Trees for Golf Event bfs

679. 24 Game dfs搜索

685. Redundant Connection II 分情况讨论出3种情况(环、入度为2的顶点,环和入度为2顶点都存在)

691. Stickers to Spell Word 状态压缩/记忆化搜索

699. Falling Squares 离散化/线段树

710. Random Pick with Blacklist hash表

726. Number of Atoms 栈的使用

780. Reaching Points 类欧几里得方法

782. Transform to Chessboard 行列独立考虑,分析棋盘性质

798. Smallest Rotation with Highest Score 考虑每个数的贡献+差分数组

803. Bricks Falling When Hit 并查集,离线做

805. Split Array With Same Average 折半搜索

810. Chalkboard XOR Game 博弈论,思考题

815. Bus Routes bfs

818. Race Car bfs,有dp做法

834. Sum of Distances in Tree 换根dp

839. Similar String Groups 并查集

850. Rectangle Area II 扫描线

864. Shortest Path to Get All Keys bfs

871. Minimum Number of Refueling Stops 优先队列,也可以dp(经过前i个加油站,加j次油能达到的最远距离)

879. Profitable Schemes 背包动态规划+容斥

882. Reachable Nodes In Subdivided Graph 最短路,堆优化dijkstra

903. Valid Permutations for DI Sequence 二维dp:O(N^3),可优化到O(N^2),中文官方题解有

913. Cat and Mouse dp, f[s][x][y] 表示当前步数为s,老鼠在x,猫在y的答案。然后用记忆化搜索去转移。 如果s大于2*n,直接返回平局。

936. Stamping The Sequence 倒着想

943. Find the Shortest Superstring 状态压缩dp,f[S][i] 考虑覆盖S的字符串,且以第i个字符串结尾时的答案长度。

975. Odd Even Jump 单调栈 dp

964. Least Operators to Express Number 转换为进制考虑 dfs

1521. Find a Value of a Mysterious Function Closest to Target 位运算&的性质

1665. Minimum Initial Energy to Finish Tasks 按照差值排序

1771. Maximize Palindrome Length From Subsequences 翻转字符串 LCS

1819. Number of Different Subsequences GCDs 枚举哪些数可能成为答案

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值