文章
[leetcode]remove-duplicates-from-sorted-list
有序链表原地消重思路有点类似于有序数组原地消重,但是由于是链表,所以有点不一样,主要是体现在表尾元素的赋值上。原理是一样的,想象成两个人,一个runner,一个walker,runner在前面找新元素(这个过程中重复元素直接扔掉delete),找到了就对walker说,我找到了!然
[leetcode]plus-one
vector<int1</int思路往前找到非9的元素,加1即可solution1需要知道vector是i可以前插的<pre<codeclassSolution{public:vector<int&g
[leetcode]length-of-last-word
RT思路:遇到空格就置计数器为0,遇到非空格就1,尤其注意“a”,这种情况,所以设置一个trash变量,存取上一次被丢弃的计数,如果最后以“”结束,就从trash中取出计数。solution1<pre<codeclassSolut
[leetcode]remove-element
原地去元素,类似原地消重solution1<pre<codeclassSolution{public:intremoveElement(intA,intn,intelem){intnew_len0;
[leetcode]remove-duplicates-from-sorted-array-ii
有序数组原地消重升级版solution1类似i问题,只是在检出新的数字的时候,继续再往后看一位就可以了<pre<codeclassSolution{public:intremoveDuplicates(intA,intn){
[leetcode]remove-duplicates-from-sorted-array
有序数组原地消重思路:所谓消重,有两种方式:字面意思:消去重复的。检出不重复的,这里采用这一种方法。solution1一旦遇到不同的数字,就存到A的前面即可。<pre<codeclassSolution{public:
[LeetCode]Longest Substring Without Repeating Characters
题目描述:<blockquote<pGivenastring,findthelengthofthelongestsubstringwithoutrepeatingcharacters.Forexample,thelongestsubstringwi
[LeetCode]Two Sum
题目描述:<blockquote<pGivenanarrayofintegers,findtwonumberssuchthattheyadduptoaspecifictargetnumber.</p<pThefunctiontwo
[LeetCode]Add Two Numbers
题目描述:<blockquote<pYouaregiventwolinkedlistsrepresentingtwononnegativenumbers.Thedigitsarestoredinreverseorderandeachoft
Conquer Leetcode in c++ (1)
写在前面:因为要准备面试,开始了在LeetCode(http://oj.leetcode.com)上刷题的历程。LeetCode上一共有大约150道题目,本文记录我在http://oj.leetcode.com(http://oj.leetcode.com)上AC的所有题目,以Leetcod
已加载文章中没有匹配内容,试试其他关键词或清空搜索。