02 2015 档案
摘要:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.思路:尼玛,各种通不过,开始用纯减法,超时了。然后用递归,溢出了。再然后终于开窍...
阅读全文
摘要:Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ...
阅读全文
摘要:Write a function to find the longest common prefix string amongst an array of strings.思路:找最长公共前缀 常规方法string longestCommonPrefix(vector &strs) { ...
阅读全文
摘要: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...
阅读全文
摘要:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ...
阅读全文
摘要:Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinki...
阅读全文
摘要:The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font fo...
阅读全文
摘要:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
阅读全文
摘要:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo...
阅读全文
摘要:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a...
阅读全文
摘要:Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one letter can be ...
阅读全文
摘要:Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exampl...
阅读全文
摘要:Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Fo...
阅读全文