随笔分类 - LeetCode
摘要:Problem Difinition:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the arr...
阅读全文
摘要:Just...Implement pow(x, n).Solution:1)Naive solution:multiply x by itself for n-1 times. (Or simply reyurn 1 if n==0).This takes O(n) time. When n is ...
阅读全文
摘要:Problem Definition:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.Solution:要求把所有存在an...
阅读全文
摘要:Problem Definition:You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-pl...
阅读全文
摘要:Problem Definition:The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the ...
阅读全文
摘要:Problem Definition:Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the following permutations:[1,2,3], [1,3,...
阅读全文
摘要:Problem Definition:Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily lar...
阅读全文
摘要:Problem Definition:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers ...
阅读全文
摘要:Problem Definition:Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to...
阅读全文
摘要:Problem Definition:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it ...
阅读全文
摘要:Problem Definition:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity...
阅读全文
摘要:Problem Definition:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrange...
阅读全文
摘要:Problem Definition:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.Solution:就是要用加减和位操作之类...
阅读全文
摘要:Problem Definition:Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as...
阅读全文
摘要:Problem Definition:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a ...
阅读全文
摘要:Problem Definition: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 quadruplet...
阅读全文
摘要:Problem Definition:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just l...
阅读全文
摘要:Problem Definition: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 ...
阅读全文
摘要:Problem Definition: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 whic...
阅读全文
摘要:Problem Definition:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Solution: 1)思路基本上就是这个样子,不...
阅读全文

浙公网安备 33010602011771号