1212#include < unordered_set>
1313#include < vector>
1414using namespace std ;
15- struct ListNode
16- {
15+ struct ListNode {
1716 int val;
1817 ListNode *next;
19- ListNode (int x) : val(x), next(NULL )
20- {
18+ ListNode (int x) : val(x), next(NULL ) {
2119 }
2220};
2321
24- struct TreeNode
25- {
22+ struct TreeNode {
2623 int val;
2724 TreeNode *left;
2825 TreeNode *right;
29- TreeNode () : val(0 ), left(nullptr ), right(nullptr )
30- {
26+ TreeNode () : val(0 ), left(nullptr ), right(nullptr ) {
3127 }
32- TreeNode (int x) : val(x), left(nullptr ), right(nullptr )
33- {
28+ TreeNode (int x) : val(x), left(nullptr ), right(nullptr ) {
3429 }
35- TreeNode (int x, TreeNode *left, TreeNode *right)
36- : val(x), left(left), right(right)
37- {
30+ TreeNode (int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {
3831 }
3932};
4033
41- namespace leetcode
42- {
43- class Solution
44- {
34+ namespace leetcode {
35+ class Solution {
4536public:
4637 std::vector<std::string> letterCombinations (std::string digits);
4738 int trap (vector<int > &height);
@@ -51,32 +42,31 @@ class Solution
5142 int findKthLargest (vector<int > &nums, int k);
5243 bool hasCycle (ListNode *head); // 环形链表
5344 ListNode *mergeTwoLists (ListNode *list1,
54- ListNode *list2); // 合并两个有序链表
45+ ListNode *list2); // 合并两个有序链表
5546 bool canVisitAllRooms (vector<vector<int >> &rooms); // 是否可以访问所有的房间
56- vector<int > findAnagrams (string s, string p); // 所有的字母异位词
47+ vector<int > findAnagrams (string s, string p); // 所有的字母异位词
5748 ListNode *removeNthFromEnd (ListNode *head, int n); // 删除链表倒数第n个节点
58- vector<vector<int >> permute (vector<int > &nums); // 全排列
59- string removeDuplicateLetters (string s); // 去除重复字母
60- vector<vector<int >> subsets (vector<int > &nums); // 求所有子集
61- vector<vector<int >> combine (int n, int k); // 组合
62- vector<string> generateParenthesis (int n); // 括号生成
63- void merge (vector<int > &nums1,
64- int m,
65- vector<int > &nums2,
66- int n); // 合并有序链表
67- vector<int > rightSideView (TreeNode *root); // 二叉树的右视图
68- int removeElement (vector<int > &nums, int val); // 移除元素
69- vector<vector<int >> levelOrder (TreeNode *root); // 二叉树的层序遍历
70- vector<int > preorderTraversal (TreeNode *root); // 二叉树的前序遍历
71- int removeDuplicates (vector<int > &nums); // 删除有序数组中的重复项
72- int longestConsecutive (vector<int > &nums); // 最长连续子序列
73- int lengthOfLIS (vector<int > &nums); // 最长递增子序列
74- int coinChange (vector<int > &coins, int amount); // 零钱兑换
75- int minFallingPathSum (vector<vector<int >> &matrix); // 最小下降路径和
76- int numDistinct (string s, string t); // 不同的子序列
77- int numSquares (int n); // 完全平方数
49+ vector<vector<int >> permute (vector<int > &nums); // 全排列
50+ string removeDuplicateLetters (string s); // 去除重复字母
51+ vector<vector<int >> subsets (vector<int > &nums); // 求所有子集
52+ vector<vector<int >> combine (int n, int k); // 组合
53+ vector<string> generateParenthesis (int n); // 括号生成
54+ void merge (vector<int > &nums1, int m, vector<int > &nums2,
55+ int n); // 合并有序链表
56+ vector<int > rightSideView (TreeNode *root); // 二叉树的右视图
57+ int removeElement (vector<int > &nums, int val); // 移除元素
58+ vector<vector<int >> levelOrder (TreeNode *root); // 二叉树的层序遍历
59+ vector<int > preorderTraversal (TreeNode *root); // 二叉树的前序遍历
60+ int removeDuplicates (vector<int > &nums); // 删除有序数组中的重复项
61+ int longestConsecutive (vector<int > &nums); // 最长连续子序列
62+ int lengthOfLIS (vector<int > &nums); // 最长递增子序列
63+ int coinChange (vector<int > &coins, int amount); // 零钱兑换
64+ int minFallingPathSum (vector<vector<int >> &matrix); // 最小下降路径和
65+ int numDistinct (string s, string t); // 不同的子序列
66+ int numSquares (int n); // 完全平方数
7867 vector<int > spiralOrder (vector<vector<int >> &matrix); // 螺旋矩阵
79- vector<vector<string>> partitionStr (string s); // 求出字符串s的所有分割子串
68+ vector<vector<string>> partitionStr (string s); // 求出字符串s的所有分割子串
69+ int longestValidParentheses (string s); // 最长有效括号
8070};
8171} // namespace leetcode
8272
0 commit comments