方法一:不进行夹逼,直接使用类似2Sum的方法,使用一个hashTable,键值对应vector中的数值,value对应vector对用数值的索引,这其中有一个小trick:最外层的循环需要出力重复数字,但是再深一层的循环判断重复数字时需要避开最外层循环的数字,如处理(-1, -1, 2)这种情况 Read More
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.思路:时间复杂度O(m*n),也就是BF(Brute... Read More
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".思路简单(同Add Two Numbers),可从代码得知,需要注意字符在字符串中的插入;co... Read More
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.//数字或字母For example,"A man, a plan, a cana... Read More
Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.思路:将单... Read More
Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... Read More
Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen... Read More
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... Read More
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu... Read More