11 2020 档案

摘要:剑指 Offer 03. 数组中重复的数字 思路:将数组进行排序,这样数组是一个有序的序列,然后判断两个相邻的数是否相等,是则返回相同的数 时间复杂度:O(nlogn) class Solution { public: int findRepeatNumber(vector<int>& nums) 阅读全文
posted @ 2020-11-23 17:49 五岁就很帅🎈 阅读(111) 评论(0) 推荐(0)
摘要:111. 二叉树的最小深度 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), 阅读全文
posted @ 2020-11-23 12:51 五岁就很帅🎈 阅读(120) 评论(0) 推荐(0)
摘要:91. 解码方法 class Solution { public: int numDecodings(string s) { int n = s.size(); s = ' ' + s; vector<int> f(n + 1); f[0] = 1; for (int i = 1; i <= n; 阅读全文
posted @ 2020-11-23 12:50 五岁就很帅🎈 阅读(101) 评论(0) 推荐(0)
摘要:71. 简化路径 class Solution { public: string simplifyPath(string path) { string res, name; if (path.back() != '/') path += '/'; for (auto c : path) { if ( 阅读全文
posted @ 2020-11-23 12:49 五岁就很帅🎈 阅读(91) 评论(0) 推荐(0)
摘要:51. N 皇后 class Solution { public: vector<vector<string>> ans; vector<string> path; vector<bool> row, col, diag, anti_diag; vector<vector<string>> solv 阅读全文
posted @ 2020-11-23 12:47 五岁就很帅🎈 阅读(93) 评论(0) 推荐(0)
摘要:31. 下一个排列 class Solution { public: void nextPermutation(vector<int>& nums) { int k = nums.size() - 1; while (k > 0 && nums[k - 1] >= nums[k]) k -- ; i 阅读全文
posted @ 2020-11-23 12:46 五岁就很帅🎈 阅读(81) 评论(0) 推荐(0)
摘要:11. 盛最多水的容器 class Solution { public: int maxArea(vector<int>& height) { int res = 0; for (int i = 0, j = height.size() - 1; i < j; ) { res = max(res, 阅读全文
posted @ 2020-11-23 12:45 五岁就很帅🎈 阅读(55) 评论(0) 推荐(0)
摘要:1. 两数之和 class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> v; for(int i = 0;i < nums.size();i++){ for(int j = i; 阅读全文
posted @ 2020-11-23 12:42 五岁就很帅🎈 阅读(75) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; #define max(x,y) ((x) > 阅读全文
posted @ 2020-11-20 12:19 五岁就很帅🎈 阅读(175) 评论(0) 推荐(0)