随笔分类 - LeetCode
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((...
阅读全文
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the c...
阅读全文
摘要:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic...
阅读全文
摘要:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephon...
阅读全文
摘要:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers....
阅读全文
摘要:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of ...
阅读全文
摘要:Write a function to find the longest common prefix string amongst an array of strings.这题是寻找一组字符串的最长公共前缀,举个例子:“abc” "a"显然lPrefixString = "a",注意检查空串的情况!...
阅读全文
摘要:题目如下:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two ...
阅读全文
摘要:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999与罗马字符转数字类似,注意按级处理。string intToRoman(int num){...
阅读全文
摘要:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.从低位开始累加,注意一下像IV和 VI DC和CD的处理class Solution {...
阅读全文
摘要:'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input string (not partial).The
阅读全文
摘要:'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input string (not partial).The...
阅读全文
摘要:回文检测,参考http://blog.csdn.net/feliciafay/article/details/16984031使用时间复杂度和空间复杂度相对较低的动态规划法来检测,具体的做法图一 偶数个回文字符情况图二 奇数个回文字符情况核心就是如果一个子串是回文,如果分别向回文左右侧扩展一个字符相...
阅读全文
摘要:Which of following C++ code is correct ?A.int f(){ int *a = new int(3); return *a;}B.int *f(){ int a[3] = {1,2,3}; return a;}C.vector f(){ vecto...
阅读全文
摘要:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ...
阅读全文
摘要:快速排序是基于分治模式的排序,它将数组a[p,...,r]分成两个子数组a[p,...q-1],a[q+1,...,r],使得a[p,...,q-1]中每个元素都小于a[q],而且小于等于a[q+1,...,r]中的元素,下标r也在计算中得到。它最坏的运行时间是o(n^2),但它的平均运行时间是o(...
阅读全文
摘要:题目是这样的:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating let...
阅读全文
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ...
阅读全文
摘要:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu...
阅读全文
摘要:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return...
阅读全文

浙公网安备 33010602011771号