08 2021 档案

摘要:https://www.nowcoder.com/discuss/711798?source_id=profile_reply_nctrack&channel=-1 阅读全文
posted @ 2021-08-31 21:24 三一一一317 阅读(88) 评论(0) 推荐(0)
摘要:题目大意:给你一系列任务的完成时间及其前置依赖,任务可以并行,求完成所有任务的最短时间 输入: 第一行一个数n代表有n个任务,接下来n行代表每个任务的信息 当没有前置依赖的时候,这一行为-1 t,t代表完成时间 当有前置依赖的时候,前置依赖间用逗号隔开,1,2 t,t代表完成时间 Java spli 阅读全文
posted @ 2021-08-31 21:23 三一一一317 阅读(245) 评论(0) 推荐(0)
摘要:题目大意: 给你一个矩阵代表一个闯关方格,英雄最开始在(0,0)处,移动一次耗费1s,闯关方格上的数字代表着倒计时,每过一秒减一,当减到0时该格子无法通过,求到右下角的最短时间 BFS搜索加剪枝即可 作者:相依相随 链接:https://www.nowcoder.com/discuss/719729 阅读全文
posted @ 2021-08-31 21:22 三一一一317 阅读(190) 评论(0) 推荐(0)
摘要:恢复内容开始 null 恢复内容结束 阅读全文
posted @ 2021-08-31 20:32 三一一一317 阅读(166) 评论(0) 推荐(0)
摘要:参考: https://www.cnblogs.com/fanguangdexiaoyuer/p/11281179.html class Solution { public: /** * longest common substring * @param str1 string字符串 the str 阅读全文
posted @ 2021-08-29 16:46 三一一一317 阅读(58) 评论(0) 推荐(0)
摘要:自动驾驶技术部_视觉3D算法工程师 所属部门: 百度 工作地点: 北京市 招聘人数: 若干 公 司: 百度 职位类别: 技术 发布时间: 2020-10-27 工作职责: -开展国际领先的计算机3D视觉算法研发 -实现可靠稳定的软件和硬件系统 -对接客户需求实现产品落地 职责要求: -具有扎实的数学 阅读全文
posted @ 2021-08-22 21:00 三一一一317 阅读(679) 评论(0) 推荐(0)
摘要:此题属于固定题,没法扩展。 class Solution { public: vector<int> findDiagonalOrder(vector<vector<int>>& mat) { int m = mat.size(); if (m == 0) return {}; int n = ma 阅读全文
posted @ 2021-08-19 15:17 三一一一317 阅读(60) 评论(0) 推荐(0)
摘要:class Solution { public: bool canMeasureWater(int jug1Capacity, int jug2Capacity, int targetCapacity) { // 两个水壶的容量之和小于目标,肯定不能得到目标值 if(jug1Capacity + j 阅读全文
posted @ 2021-08-19 14:34 三一一一317 阅读(76) 评论(0) 推荐(0)
摘要:class Solution { public: bool canFinish(int numCourses, vector<vector<int>>& prerequisites) { if(numCourses==0) return false; vector<vector<int>> edge 阅读全文
posted @ 2021-08-19 14:09 三一一一317 阅读(103) 评论(0) 推荐(0)
摘要:class Solution { public: static bool cmp(vector<int> &a, vector<int> &b){ if(a[0]!=b[0]) return a[0]<b[0]; else return a[1]<b[1]; } int maxEvents(vect 阅读全文
posted @ 2021-08-19 12:52 三一一一317 阅读(56) 评论(0) 推荐(0)
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), rig 阅读全文
posted @ 2021-08-19 10:20 三一一一317 阅读(58) 评论(0) 推荐(0)
摘要:class Solution { public: int nthUglyNumber(int n) { int a = 0; int b = 0; int c = 0; vector<int> res(n,1); for(int i = 1; i < n; i++){ int temp = min( 阅读全文
posted @ 2021-08-18 21:36 三一一一317 阅读(41) 评论(0) 推荐(0)
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), rig 阅读全文
posted @ 2021-08-18 15:03 三一一一317 阅读(138) 评论(0) 推荐(0)
摘要:class Solution { public: vector<vector<int>> res; vector<vector<int>> permute(vector<int>& nums) { vector<int> temp; for(int i = 0; i < nums.size(); i 阅读全文
posted @ 2021-08-18 14:59 三一一一317 阅读(45) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : 阅读全文
posted @ 2021-08-18 14:58 三一一一317 阅读(58) 评论(0) 推荐(0)
摘要:参考: https://leetcode-cn.com/problems/factorial-trailing-zeroes/solution/xiang-xi-tong-su-de-si-lu-fen-xi-by-windliang-3/ class Solution { public: int 阅读全文
posted @ 2021-08-18 14:56 三一一一317 阅读(56) 评论(0) 推荐(0)
摘要:三面列举了三种不同最小值所在的位置,可以看出只要当前元素为1,那么dp[i][j]就等于左上,左、上,中的最小值加1。 比如图一种最小值为3。问号所在位置元素为1,那么dp问号处的值就为4,因为当取三者最小值的时候,其余两个4,4所在位置的元素肯定为1。不然此处的dp值肯定比3还小。 class S 阅读全文
posted @ 2021-08-18 13:54 三一一一317 阅读(54) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : 阅读全文
posted @ 2021-08-18 12:34 三一一一317 阅读(67) 评论(0) 推荐(0)
摘要:class Solution { public: int maxSubArray(vector<int>& nums) { int res = INT_MIN; int sum = 0; for(int i = 0; i < nums.size(); i++){ if(sum<=0){ sum = 阅读全文
posted @ 2021-08-18 11:53 三一一一317 阅读(45) 评论(0) 推荐(0)
摘要:class Solution { public: void moveZeroes(vector<int>& nums) { int i = 0; int j = 0; while(j<nums.size()){ if(nums[j]!=0){ swap(nums[i],nums[j]); i++; 阅读全文
posted @ 2021-08-18 11:44 三一一一317 阅读(42) 评论(0) 推荐(0)
摘要:class Solution { public: /* 小于10,1~9,9个数字,9位 小于100,10~99,90个数字,180位 小于1000,100~999,900个数字,2700位 */ int findNthDigit(int n) { long digit = 1; // 用来记录n属 阅读全文
posted @ 2021-08-18 11:33 三一一一317 阅读(70) 评论(0) 推荐(0)
摘要:第一种dfs,用例还剩最后一个超时了 class Solution { public: int res = INT_MAX; // int m = 0; // int n = 0; int minimumTotal(vector<vector<int>>& triangle) { // m = tr 阅读全文
posted @ 2021-08-17 21:38 三一一一317 阅读(60) 评论(0) 推荐(0)
摘要:class Solution { public: vector<string> split(string str, string flag){ vector<string> res; int fd = 0; // 注意前面是赋值。fd = str.find(flag) // 后面是判断,如果fd = 阅读全文
posted @ 2021-08-17 20:39 三一一一317 阅读(53) 评论(0) 推荐(0)
摘要:参考: https://www.bilibili.com/video/BV1Tz4y167pC?from=search&seid=6576840001001728880 class Solution { public: string removeDuplicateLetters(string s) 阅读全文
posted @ 2021-08-17 19:40 三一一一317 阅读(79) 评论(0) 推荐(0)
摘要:class Solution { public: vector<vector<int>> threeSum(vector<int>& nums) { vector<vector<int>> res; sort(nums.begin(), nums.end()); // 排序,方便后续处理 for(i 阅读全文
posted @ 2021-08-17 16:22 三一一一317 阅读(65) 评论(0) 推荐(0)
摘要:class Solution { public: vector<int> addToArrayForm(vector<int>& num, int k) { vector<int> vec; string str_k = to_string(k); // cout<<"num: "<<num.siz 阅读全文
posted @ 2021-08-17 15:32 三一一一317 阅读(56) 评论(0) 推荐(0)
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), rig 阅读全文
posted @ 2021-08-16 20:08 三一一一317 阅读(47) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solu 阅读全文
posted @ 2021-08-16 19:24 三一一一317 阅读(65) 评论(0) 推荐(0)
摘要:class Solution { public: void nextPermutation(vector<int>& nums) { // 我要比你大,还大的最小 // 较小数尽量靠右, 所以从右往前找 // 较大数尽可能小 int i = nums.size()-2; // 寻找较小数 while 阅读全文
posted @ 2021-08-16 18:55 三一一一317 阅读(40) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : 阅读全文
posted @ 2021-08-16 17:40 三一一一317 阅读(43) 评论(0) 推荐(0)
摘要:class Solution { public: vector<int> fairCandySwap(vector<int>& aliceSizes, vector<int>& bobSizes) { int sum1 = 0; int sum2 = 0; for(int i = 0; i < al 阅读全文
posted @ 2021-08-16 17:16 三一一一317 阅读(49) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : 阅读全文
posted @ 2021-08-16 17:16 三一一一317 阅读(41) 评论(0) 推荐(0)
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), rig 阅读全文
posted @ 2021-08-15 15:49 三一一一317 阅读(49) 评论(0) 推荐(0)
摘要:class Solution { public: static bool cmp(vector<int> &a, vector<int> &b){ // if(a[0]!=b[0]) return a[0]<b[0]; // else // return a[1]<b[1]; } vector<ve 阅读全文
posted @ 2021-08-15 14:53 三一一一317 阅读(75) 评论(0) 推荐(0)
摘要:class Solution { public: int longestOnes(vector<int>& nums, int k) { unordered_map<int,int> un_map; int sum = 0; int i = 0; int j = 0; for(j = 0; j < 阅读全文
posted @ 2021-08-15 14:20 三一一一317 阅读(44) 评论(0) 推荐(0)
摘要:class Solution { public: vector<vector<int>> findContinuousSequence(int target) { int n = target/2; int i = 1; int j = 1; int sum = 0; vector<vector<i 阅读全文
posted @ 2021-08-15 13:11 三一一一317 阅读(40) 评论(0) 推荐(0)
摘要:// /** // * Definition for a binary tree node. // * struct TreeNode { // * int val; // * TreeNode *left; // * TreeNode *right; // * TreeNode() : val(0 阅读全文
posted @ 2021-08-15 12:35 三一一一317 阅读(81) 评论(0) 推荐(0)
摘要:解析: https://www.cnblogs.com/gzshan/p/10904273.html?ivk_sa=1024320u class Solution { public: vector<int> maxSlidingWindow(vector<int>& nums, int k) { d 阅读全文
posted @ 2021-08-15 12:13 三一一一317 阅读(95) 评论(0) 推荐(0)
摘要:class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> res; unordered_map<int,int> un_map; for(int i = 0; i < nums.s 阅读全文
posted @ 2021-08-14 19:27 三一一一317 阅读(62) 评论(0) 推荐(0)
摘要:参考: https://leetcode-cn.com/problems/longest-increasing-subsequence/solution/dong-tai-gui-hua-er-fen-cha-zhao-tan-xin-suan-fa-p/ class Solution { publ 阅读全文
posted @ 2021-08-14 19:13 三一一一317 阅读(53) 评论(0) 推荐(0)
摘要:class Solution { public: int minSubArrayLen(int target, vector<int>& nums) { int maxsize = INT_MAX; int left = 0; int right = 0; int sum = 0; while(ri 阅读全文
posted @ 2021-08-14 18:49 三一一一317 阅读(55) 评论(0) 推荐(0)
摘要:class Solution { public: //vector<vector<int>> res; int res = 0; int count_0 = 0; int uniquePathsIII(vector<vector<int>>& grid) { int m = grid.size(); 阅读全文
posted @ 2021-08-14 18:06 三一一一317 阅读(100) 评论(0) 推荐(0)
摘要:class Solution { public: int nthUglyNumber(int n) { vector<int> res(n,1); int a = 0; int b = 0; int c = 0; for(int i = 1; i < n; i++){ // 定义三个指针分别维护 2 阅读全文
posted @ 2021-08-14 17:13 三一一一317 阅读(39) 评论(0) 推荐(0)
摘要:class Solution { public: int characterReplacement(string s, int k) { unordered_map<char,int> un_map; int left = 0; int res = 0; int maxval = 0; for(in 阅读全文
posted @ 2021-08-14 16:43 三一一一317 阅读(60) 评论(0) 推荐(0)
摘要:用到hash表+堆 class Solution { public: string reorganizeString(string s) { map<char, int> maps; // 对于偶数n而言,如果出现最多字母个数超过n/2,则肯定有两相邻元素相同。 // 对于奇数而言,如果出现最多字母 阅读全文
posted @ 2021-08-14 15:40 三一一一317 阅读(68) 评论(0) 推荐(0)
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : 阅读全文
posted @ 2021-08-14 00:39 三一一一317 阅读(95) 评论(0) 推荐(0)
摘要:class Solution { public: vector<int> spiralOrder(vector<vector<int>>& matrix) { vector<int> res; int t = 0; int b = matrix.size()-1; int l = 0; int r 阅读全文
posted @ 2021-08-13 20:38 三一一一317 阅读(105) 评论(0) 推荐(0)
摘要:class Solution { public: int leastBricks(vector<vector<int>>& wall) { unordered_map<int,int> un_map; if(wall.size()==0) return 0; for(int i = 0; i < w 阅读全文
posted @ 2021-08-13 20:13 三一一一317 阅读(63) 评论(0) 推荐(0)
摘要:参考: https://leetcode-cn.com/problems/combination-sum-ii/solution/hui-su-suan-fa-jian-zhi-python-dai-ma-java-dai-m-3/ class Solution { public: vector<v 阅读全文
posted @ 2021-08-13 17:43 三一一一317 阅读(38) 评论(0) 推荐(0)
摘要:class Solution { public: vector<vector<int>> res; vector<vector<int>> permuteUnique(vector<int>& nums) { vector<int> temp; for(int i = 0; i < nums.siz 阅读全文
posted @ 2021-08-13 16:14 三一一一317 阅读(45) 评论(0) 推荐(0)
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), rig 阅读全文
posted @ 2021-08-13 13:39 三一一一317 阅读(20) 评论(0) 推荐(0)
摘要:思想很重要 class Solution { public: void solve(vector<vector<char>>& board) { int m = board.size(); int n = board[0].size(); // 从边缘开始,因为四周肯定不被包围,和四周O联通的先调用 阅读全文
posted @ 2021-08-13 12:04 三一一一317 阅读(39) 评论(0) 推荐(0)
摘要:class Solution { public: bool exist(vector<vector<char>>& board, string word) { int m = board.size(); int n = board[0].size(); bool res = false; vecto 阅读全文
posted @ 2021-08-12 20:01 三一一一317 阅读(36) 评论(0) 推荐(0)
摘要:class Solution { public: vector<vector<int>> res; vector<vector<int>> combine(int n, int k) { vector<int> temp; vector<int> nums; // 构建一个nums数组避免下标0数字 阅读全文
posted @ 2021-08-12 18:19 三一一一317 阅读(40) 评论(0) 推荐(0)
摘要:class Solution { public: vector<vector<int>> res; vector<vector<int>> permute(vector<int>& nums) { vector<int> temp; for(int i = 0; i < nums.size(); i 阅读全文
posted @ 2021-08-12 17:15 三一一一317 阅读(40) 评论(0) 推荐(0)
摘要:解析参考: https://leetcode-cn.com/problems/pacific-atlantic-water-flow/solution/shui-wang-gao-chu-liu-by-xiaohu9527-xxsx/ class Solution { public: vector< 阅读全文
posted @ 2021-08-12 16:44 三一一一317 阅读(69) 评论(0) 推荐(0)
摘要:class Solution { public: int findCircleNum(vector<vector<int>>& isConnected) { int count = 0; int m = isConnected.size(); vector<bool> visited(m,false 阅读全文
posted @ 2021-08-12 15:28 三一一一317 阅读(43) 评论(0) 推荐(0)
摘要:class Solution { public: int maxAreaOfIsland(vector<vector<int>>& grid) { int maxarea = 0; int m = grid.size(); int n = grid[0].size(); if(m==0||n==0) 阅读全文
posted @ 2021-08-12 14:52 三一一一317 阅读(37) 评论(0) 推荐(0)
摘要:class Solution { public: void sortColors(vector<int>& nums) { int i = 0; int j = nums.size()-1; int left = 0; int right = nums.size()-1; // 遍for循环,第一遍 阅读全文
posted @ 2021-08-12 13:15 三一一一317 阅读(44) 评论(0) 推荐(0)
摘要:class Solution { public: int trap(vector<int>& height) { vector<int> left(height.size(),0); vector<int> right(height.size(),0); int lefttemp = 0; int 阅读全文
posted @ 2021-08-12 11:12 三一一一317 阅读(29) 评论(0) 推荐(0)
摘要:// // 这种方法超时了 // class Solution { // public: // static bool cmp(pair <char,int> &a, pair <char,int> &b){ // return a.second > b.second; // } // string 阅读全文
posted @ 2021-08-11 00:23 三一一一317 阅读(35) 评论(0) 推荐(0)
摘要:变量存放的位置 C/C++程序占用的内存分为以下几部分: 程序代码区常量区存放常量。程序结束时由OS回收。全局区(静态区)存放全局变量和静态变量。初始化的全局变量和静态变量在一块区域,未初始化的全局变量和未初始化的静态变量在相邻的另一块区域。 程序结束时由OS回收。堆区存放的变量(用new,mall 阅读全文
posted @ 2021-08-10 20:34 三一一一317 阅读(110) 评论(0) 推荐(0)
摘要:class Solution { public: int findMin(vector<int>& nums) { int l = 0; int r = nums.size()-1; while(l<=r){ int mid = l + (r-l)/2; if(nums[mid]==nums[r]) 阅读全文
posted @ 2021-08-10 19:21 三一一一317 阅读(28) 评论(0) 推荐(0)
摘要:双指针: class Solution { public: string findLongestWord(string s, vector<string>& dictionary) { string res; for(int i = 0; i < dictionary.size(); i++){ i 阅读全文
posted @ 2021-08-10 17:33 三一一一317 阅读(44) 评论(0) 推荐(0)
摘要:这题不用双指针也挺简 class Solution { public: bool validPalindrome(string s) { int i = 0; int j = s.size()-1; int cnt = 0; while(i<j){ if(s[i]!=s[j]){ return is 阅读全文
posted @ 2021-08-10 17:00 三一一一317 阅读(32) 评论(0) 推荐(0)
摘要:我的第一直觉是hashmap,可能受两数之和的影响 class Solution { public: bool judgeSquareSum(int c) { unordered_map<int, int> un_map; double n = sqrt(c); for(int i = 0; i < 阅读全文
posted @ 2021-08-10 16:33 三一一一317 阅读(41) 评论(0) 推荐(0)
摘要:解析参考:非常详细 https://blog.csdn.net/weixin_45629285/article/details/118674829 class Solution { public: string minWindow(string s, string t) { unordered_ma 阅读全文
posted @ 2021-08-10 16:10 三一一一317 阅读(37) 评论(0) 推荐(0)
摘要:class Solution { public: bool checkPossibility(vector<int>& nums) { vector<int> res; int count = 0; for(int i = 0; i < nums.size()-1; i++){ if(nums[i] 阅读全文
posted @ 2021-08-09 19:58 三一一一317 阅读(42) 评论(0) 推荐(0)
摘要:class Solution { public: static bool cmp(vector<int> &a, vector<int> &b){ if(a[0] != b[0]) // 第一个元素不等,先按照第一个元素从大到小排序 return a[0]>b[0]; else return a[1 阅读全文
posted @ 2021-08-09 17:03 三一一一317 阅读(27) 评论(0) 推荐(0)
摘要:这题可以用动态规划。 题目中指出:注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。但是没有没有提及 同一天不能发生两笔交易 因此可以用贪心算法。因为贪心算法中同一天先卖出后买入。 class Solution { public: int maxProfit(vector<int> 阅读全文
posted @ 2021-08-09 16:24 三一一一317 阅读(32) 评论(0) 推荐(0)
摘要:class Solution { public: vector<int> partitionLabels(string s) { vector<int> res; int map[26]; for(int i = 0; i < s.length(); i++){ map[s[i]-'a'] = i; 阅读全文
posted @ 2021-08-09 15:59 三一一一317 阅读(34) 评论(0) 推荐(0)
摘要:class Solution { public: static bool cmp(vector<int> &a, vector<int> &b){ return a[1]<b[1]; } int findMinArrowShots(vector<vector<int>>& points) { // 阅读全文
posted @ 2021-08-09 15:15 三一一一317 阅读(42) 评论(0) 推荐(0)
摘要:class Solution { public: bool canPlaceFlowers(vector<int>& flowerbed, int n) { int count = 0; int len = flowerbed.size(); // 针对长度为0的情况 if(len==0) retu 阅读全文
posted @ 2021-08-09 14:49 三一一一317 阅读(48) 评论(0) 推荐(0)
摘要:class Solution { public: // 注意必须加上&符号,不然超时报错,因为加引用是地址传递, // 不加会创建一个新的变量,和原来的变量指向同一个地址 static int cmp(vector<int> &a, vector<int> &b){ return a[1]<b[1] 阅读全文
posted @ 2021-08-09 12:49 三一一一317 阅读(29) 评论(0) 推荐(0)