LeetCode 所有题目总结
文章目录
- 做题注意事项
- 题目分类
- 1.位运算
- 2.字符串题型
- 3.TopK 问题--最大堆/最小堆
- 4.链表
- 5.动态规划
- easy
- Medium
- hard
- 6.贪心
- 7.树
- 8.图
- 9.数学题
- 10.数据库-SQL
- 11.栈和队列
- 12.矩阵
- 13.数组
- 14.买股票系列题目
- 15.智力题
- 16.并发
- 17.线段树
- 真实笔试,面试题
- 其他--简单题
做题注意事项
1.注意空字符串,以及各种极端情况。
2.异或运算有奇效。
3.小心数组的开始和结束条件。
static bool _foo = ios::sync_with_stdio(false);
题目分类
1.位运算
- LeetCode 136. Single Number–2个数直接异或–Java,C++,Python解法
- LeetCode 137. Single Number II–三次异或消除相同的数–C++,Python解法
seen_once = ~seen_twice & (seen_once ^ num)seen_twice = ~seen_once & (seen_twice ^ num)
- LeetCode 421. Maximum XOR of Two Numbers in an Array–Python解法
2.字符串题型
具有最多两个不同字符的最长子串的长度
- LeetCode 159. Longest Substring with At Most Two Distinct Characters --Java,C++,Python解法
- LeetCode 771. Jewels and Stones–Java和Python解法–简单
- LeetCode 438. Find All Anagrams in a String–字符串-滑动窗口–C++,Python解法
3.TopK 问题–最大堆/最小堆
- LeetCode 215. Kth Largest Element in an Array–数字第K大的元素–最大堆或优先队列–C++,Python解法
- LeetCode 973. K Closest Points to Origin–TopK 问题–最小堆–C++,Python解法
import heapq
l = heapq.nlargest(2, [3, 2, 1, 5, 6, 4])
4.链表
- LeetCode 206 Reverse Linked List–反转链表–迭代与递归解法–递归使用一个临时变量,迭代使用3个
- LeetCode 21. Merge Two Sorted Lists–合并2个有序列表–python递归,迭代解法
- LeetCode 23. Merge k Sorted Lists–Python解法–优先队列,分治法
- LeetCode 141. Linked List Cycle–百度面试编程题–C++,Python解法
判断链表是否成环,使用快慢指针。 - LeetCode 142. Linked List Cycle II–单向链表成环的起点–C++,Python解法
求成环起点 - LeetCode 2. Add Two Numbers–C++,Python解法
- LeetCode 445. Add Two Numbers II–字节跳动面试算法题–C++,Python解法
- LeetCode 369. Plus One Linked List–链表–C++,Python解法
- LeetCode 148. Sort List–拼多多面试算法题–C++,Python解法
- LeetCode 92. Reverse Linked List II–Python 解法–反转部分链表–笔试算法题
5.动态规划
easy
- LeetCode 509. Fibonacci Number–Python解法
- LeetCode 198. House Robber–动态规划–C++,Java,Python解法 - zhangpeterx的博客 - CSDN博客
- LetCode 70. Climbing Stairs–动态规划-爬梯子–递归等解法 - zhangpeterx的博客 - CSDN博客
- LeetCode 121. Best Time to Buy and Sell Stock–动态规划–Java,Python,C++解法 - zhangpeterx的博客 - CSDN博客
- LeetCode 746. Min Cost Climbing Stairs–动态规划–Java,C++,Python解法 - zhangpeterx的博客 - CSDN博客
- LeetCode 53. Maximum Subarray–动态规划–C++,Python解法
Medium
- LeetCode 583. Delete Operation for Two Strings–动态规划 DP–Java,Python,C++解法 - zhangpeterx的博客 - CSDN博客
- LeetCode 91. Decode Ways–动态规划DP的Python和Java解法 - zhangpeterx的博客 - CSDN博客
- LeetCode 152. Maximum Product Subarray–动态规划–C++,Python解法
- LeetCode 221. Maximal Square----动态规划–谷歌面试算法题–Python解法
- LeetCode 542. 01 Matrix–C++解法–动态规划
- LeetCode 542. 01 Matrix–C++解法–动态规划
hard
- LeetCode 72. Edit Distance - zhangpeterx的博客 - CSDN博客
- LeetCode 45. Jump Game II–Python解法–动态规划
6.贪心
- LeetCode 122. Best Time to Buy and Sell Stock II–贪心–Java,C++,Python解法
7.树
- LeetCode 104. Maximum Depth of Binary Tree–二叉树高度–递归或迭代–C++,Python解法
- LeetCode 226. Invert Binary Tree–反转二叉树–递归或迭代–C++,Python解法
- LeetCode 94. Binary Tree Inorder Traversal–二叉树中序遍历–递归,迭代–C++,Python解法
- LeetCode 144. Binary Tree Preorder Traversal–二叉树前序遍历–反向压栈–迭代-栈,递归–C++,Python解法
- LeetCode 145. Binary Tree Postorder Traversal–后序遍历–先序遍历反向输出–递归,迭代–C++,Python解法
- LeetCode 589. N-ary Tree Preorder Traversal-多子节点树前序遍历–递归,迭代–反向压栈–C++解法
- LeetCode 98. Validate Binary Search Tree–C++解法–判断是否是BST–递归,迭代做法,中序遍历
- LeetCode 230. Kth Smallest Element in a BST–C++,Python解法–面试真题–找二叉树中第K小的元素
- LeetCode 965 Univalued Binary Tree–判断二叉树的所有节点的值是否相同–python,java解法
- LeetCode 426. Convert Binary Search Tree to Sorted Doubly Linked List-转换二叉树为双向链表–Java,C++,Python解法
- LeetCode 105 Construct Binary Tree from Preorder and Inorder Traversal–前序中序遍历构造二叉树-Python和Java递归,迭代解法
- LeetCode 102. Binary Tree Level Order Traversal–递归,迭代-Python,Java解法
- LeetCode 226. Invert Binary Tree–反转二叉树–C++,Python解法–递归,迭代做法
8.图
- LeetCode 547. Friend Circles–Python解法–笔试算法题
- LeetCode 207. Course Schedule–有向图找环–面试算法题–DFS递归,拓扑排序迭代–Python
- LeetCode 399. Evaluate Division–Python-DFS解法
9.数学题
- LeetCode 204. Count Primes–从一开始的质数个数–C++,Python解法
不要一个一个算,快速迭代。 - LeetCode 829. Consecutive Numbers Sum–B站笔试题–C++解法
时间复杂度O(sqrt(n)) - LeetCode 264. Ugly Number II–C++,Python解法
- LeetCode 202. Happy Number–Python解法
- LeetCode 54. Spiral Matrix–Python解法–螺旋排序
- LeetCode 167. Two Sum II - Input array is sorted–Python解法
- LeetCode 974. Subarray Sums Divisible by K–Python解法–数学题–取模求余
- LeetCode 319. Bulb Switcher–C++,java,python 1行解法–数学题
- LeetCode 268. Missing Number–Python解法–数学题
- LeetCode 202. Happy Number–Python解法–数学题
- LeetCode 31. Next Permutation-- Python 解法–数学题–比当前数大的最小的数
- LeetCode 123. Best Time to Buy and Sell Stock III–Python解法–动态规划–数学题
- LeetCode 41. First Missing Positive–Python 解法–数学题-找到不存在的最小正整数-O(1)空间复杂度
10.数据库-SQL
- LeetCode 175. Combine Two Tables–Database–数据库题目
- LeetCode 176. Second Highest Salary–Database–数据库题目
- LeetCode 595 Big Countries: SQL的题
11.栈和队列
- LeetCode 232. Implement Queue using Stacks–用2个栈来实现一个队列–C++解法
- LeetCode 225. Implement Stack using Queues–用队列实现栈–C++解法
12.矩阵
- LeetCode 542. 01 Matrix–C++解法–动态规划
- LeetCode 74. Search a 2D Matrix–有序矩阵查找–python,java,c++解法
13.数组
- LeetCode 961 N-Repeated Element in Size 2N Array --python,java解法
- LeetCode 421. Maximum XOR of Two Numbers in an Array–Python解法
- LeetCode 167. Two Sum II - Input array is sorted–Python解法
- LeetCode 974. Subarray Sums Divisible by K–Python解法–数学题–取模求余
- LeetCode 152. Maximum Product Subarray–动态规划–C++,Python解法
- LeetCode 53. Maximum Subarray–动态规划–C++,Python解法
- LeetCode 215. Kth Largest Element in an Array–数字第K大的元素–最大堆或优先队列–C++,Python解法
14.买股票系列题目
- LeetCode 121. Best Time to Buy and Sell Stock–Java,Python,C++解法
- LeetCode 122. Best Time to Buy and Sell Stock II–贪心–Java,C++,Python解法
- LeetCode 123. Best Time to Buy and Sell Stock III–Python解法–动态规划–数学题
- LeetCode 309. Best Time to Buy and Sell Stock with Cooldown–Java解法-卖股票系列题目
15.智力题
- LeetCode 458. Poor Pigs–智力题「小白鼠试毒」–C++,Python解法
16.并发
- LeetCode 1114. Print in Order–Java解法–并发问题
- LeetCode 1115. Print FooBar Alternately–多线程并发问题–Java解法–CyclicBarrier, synchronized, Semaphore 信号量
- LeetCode1117. Building H2O --Java解法–多线程保证执行顺序–AtomicInteger
- LeetCode 1188. Design Bounded Blocking Queue–并发系列–Java 解法–设计有界阻塞队列–使用ArrayBlockingQueue和LinkedList
17.线段树
- 数据结构线段树介绍与笔试算法题-LeetCode 307. Range Sum Query - Mutable–Java解法
真实笔试,面试题
- LeetCode 468. Validate IP Address–笔试题–Python解法
- LeetCode 141. Linked List Cycle–面试编程题–C++,Python解法
- LeetCode 1027. Longest Arithmetic Sequence–笔试题–C++解法
- LeetCode 17. Letter Combinations of a Phone Number–笔试题–C++,Python解法
- LeetCode 829. Consecutive Numbers Sum–笔试题–C++解法
- LeetCode 204. Count Primes–从一开始的质数个数–C++,Python解法
- LeetCode 445. Add Two Numbers II–面试算法题–C++,Python解法
- LeetCode 93. Restore IP Addresses–面试算法题–Python解法
- LeetCode 20. Valid Parentheses–笔试题–Python解法
- LeetCode 42. Trapping Rain Water–笔试算法题–c++解法
- LeetCode 148. Sort List–面试算法题–C++,Python解法
- LeetCode 221. Maximal Square----动态规划–谷歌面试算法题–Python解法
- LeetCode 230. Kth Smallest Element in a BST–C++,Python解法–面试真题–找二叉树中第K小的元素
- LeetCode 547. Friend Circles–Python解法–笔试算法题
- LeetCode 226. Invert Binary Tree–反转二叉树–C++,Python解法–递归,迭代做法
Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so f*** off. - LeetCode 542. 01 Matrix–C++解法–动态规划
- LeetCode 92. Reverse Linked List II–Python 解法–反转部分链表–笔试算法题
其他–简单题
- 单纯的排序:LeetCode 75. Sort Colors–Python解法
- LeetCode 121. Best Time to Buy and Sell Stock–Java,Python,C++解法
- LeetCode 1108. Defanging an IP Address–C++,Python解法
- LeetCode 804 Unique Morse Code Words–python,java解法
- LeetCode 709 To Lower Case – java,python解法
- LeetCode 929 Unique Email Addresses–python一行解法,Java解法
- LeetCode 217 Contains Duplicate–python,java解法–set–简单
- LeetCode 657 : Robot Return to Origin
- LeetCode 905 Sort Array By Parity–Java stream,Python lambda表达式一行 解法
- LeetCode 22. Generate Parentheses–Python 解法–广度优先、深度优先解法 — zhang0peter的个人博客
LeetCode 所有题目总结相关推荐
- leetcode LRUCache题目
leetcode LRUCache题目 package com.jackiesteed.leetcode;import java.util.*;/*** Created by jackie on 4/ ...
- 【持续更新】Leetcode SQL题目全解析(附建表sql)
Leetcode SQL题目全解析 越前须知(雾) 题目Q & A 175 组合两个表 181 超过经理收入的员工 182 查找重复电子邮箱 183 从不订购的用户 197 上升的温度 511 ...
- LeetCode数据库题目1-123
LeetCode数据库题目1-123 175. 组合两个表 难度简单 SQL架构 表1: Person +-------------+---------+ | 列名 | 类型 | +--------- ...
- 算法思想-深度搜索算法-leetcode相关题目总结
通过这篇文章你能学到什么 搜索算法 深度优先搜索 分析过程 实现代码 进出栈过程示意图 DFS算法应用-Leetcode相关题目 Leetcode 78 Subsets Leetcode 90 Sub ...
- java 套娃_【leetcode编程题目354】俄罗斯套娃
来自 https://leetcode.com/problems/russian-doll-envelopes/ You have a number of envelopes with widths ...
- 【LeetCode刷题记录】LeetCode经典题目数组求和及哈希表的使用!
点上方蓝字计算机视觉联盟获取更多干货 在右上方 ··· 设为星标 ★,与你不见不散 LeetCode题目 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那两个整 ...
- LeetCode简单题目(#263 #268 #278 #283 #290)-5道(数字、字符串)
leetcode题库中共有350道简单题目. 本文记录已解决的题目和代码. 本文中的序号是leetcode题目中的真实序号. 文章目录 263 丑数 描述 代码 大神代码 268 缺失数字 描述 代码 ...
- LeetCode简单题目(#235 #237 #242 #257 #258)-5道(树、数字、字符串)
leetcode题库中共有350道简单题目. 本文记录已解决的题目和代码. 本文中的序号是leetcode题目中的真实序号. 文章目录 235 二叉搜索树的最近公共祖先 描述 代码 237 删除链表中 ...
- LeetCode简单题目(#225 #226 #231 #232 #234)-5道(栈、队列、树、数字)
leetcode题库中共有350道简单题目. 本文记录已解决的题目和代码. 本文中的序号是leetcode题目中的真实序号. 文章目录 225 用队列实现栈 描述 代码 226 翻转二叉树 描述 代码 ...
最新文章
- 如何解决动态查询语句太长,大于数据库字符的最大长度
- python 多进程 multiprocessing.Queue()报错:The freeze_support() line can be omitted if the program
- 免费字典api ,查询汉字完整信息
- synctoy 自动同步_用SyncToy给硬盘备份保证数据安全,来自微软的馅饼真香
- 定位的特殊特性(HTML、CSS)
- Mysql 高负载排查思路
- 【JAVA笔记——器】Spring MVC + HATEOAS RestFul快速搭建
- ADO.NET 数据库操作类
- Echar柱状堆叠图X轴自定义显示功能
- 如何让Loadrunner或Jmeter发送邮件报告
- shell中的let命令
- 电子警察系统设计(原理+流程+论文)
- Android 手动显示和隐藏软键盘
- PV,VG,LV的关系和操作
- 反问疑问_反问疑问句的用法
- Google学术的使用指南
- 计算机公式与函数试题,计算机国考样题EXCEL之公式与函数的应用一
- HCM 初学 ( 二 ) - 信息类型
- AirPlay视频SDK集成
- ST 电机控制工作台帮助文档翻译 之 使用 ST 电机控制工作台(工作台(帮助菜单命令))
热门文章
- Android逆向分析工具ded的使用
- oracle中SQL语句ge的用法,Oracle中SQL语句的几种用法
- 命名管道 win7未响应_大数据分析Python建立分析数据管道
- PICRUSt2软件
- BMC Plant biology:高丰度青枯菌改变了番茄根际微生物组和代谢组
- Microbiome:城市海滩和污水中抗生素抗性组研究
- R语言分类模型:逻辑回归模型LR、决策树DT、推理决策树CDT、随机森林RF、支持向量机SVM、Rattle可视化界面数据挖掘、分类模型评估指标(准确度、敏感度、特异度、PPV、NPV)
- pandas使用extract函数根据正则表达式从dataframe指定数据列的字符串中抽取出数字(设置expand=false之后返回的为series)、将series转化为dataframe
- R语言对dataframe进行行数据筛选(row selection)多种方案:使用R原生方法、data.table、dplyr等方案
- python可视化脉搏和血氧数据并通过阈值动态调整、动态可视化异常值