LeetCode
景天的天
我害怕你心碎没人帮你擦眼泪
展开
-
leetcode杂记
回溯+剪枝的简易实现方式,比较典型的39.Combination Sum,在dfs的函数的for循环里面直接加上判断来实现剪枝,同时事先sort来去除重复,这道题目其实非常典型。 void DFS(int st, int num, int target, vector<int>& candidates){ if(num == target){ ans.push_back(path); return;原创 2020-06-22 20:28:33 · 197 阅读 · 0 评论 -
LeetCode 1.Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use th...原创 2018-03-13 22:33:29 · 145 阅读 · 0 评论 -
LeetCode 2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and retur...原创 2018-06-08 16:33:07 · 148 阅读 · 0 评论 -
LeetCode 3.Longest Substring Without Repeating Characters
这个题目超级搞,也不知道为啥缺少了map的判断键值条件dic.find(s[i])!=dic.end()之后就会出错。最直接的就是只含有一个字符的字符串,它的最长子串会认定长度是0,直到现在也不知道为啥,只能说以后map还是尽量加上find(),防止出现一些诡异的错误。 然后贴一篇讲的很好的博客 class Solution { public: int lengthOfLonges...原创 2018-06-19 09:25:42 · 164 阅读 · 0 评论