
leetcode
文章平均质量分 61
k829593756
这个作者很懒,什么都没留下…
展开
-
LeetCode 15 3Sum
原题:(此题高频) 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 zer原创 2017-10-12 11:08:59 · 130 阅读 · 0 评论 -
LeetCode 49 Group Anagrams
原题:(频率4) Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:原创 2017-10-23 13:42:55 · 132 阅读 · 0 评论 -
LeetCode 43 Multiply Strings
原题:(频率3) Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2. Note: The length原创 2017-10-23 13:38:33 · 134 阅读 · 0 评论 -
LeetCode 22 Generate Parentheses
原题:(频率4) Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3,原创 2017-10-23 13:19:19 · 136 阅读 · 0 评论 -
LeetCode 17 Letter Combinations of a Phone Number
原题:(频率3) Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just li原创 2017-10-19 16:06:51 · 156 阅读 · 0 评论 -
LeetCode 63
原题: Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 respectively原创 2017-10-06 20:30:43 · 267 阅读 · 0 评论 -
LeetCode 80
原题: Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, Given sorted array nums = [1,1,1,2,2,3], Your function should return length = 5原创 2017-10-09 21:07:51 · 293 阅读 · 0 评论 -
LeetCode 59 Spiral Matrix II
原题:(频率2) Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime com原创 2017-10-13 15:24:05 · 145 阅读 · 0 评论 -
LeetCode 56 Merge Intervals
原题:(频率5) Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,原创 2017-10-13 15:04:46 · 161 阅读 · 0 评论 -
LeetCode 55 Jump Game
原题:(频率2) Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents y原创 2017-10-13 14:33:29 · 138 阅读 · 0 评论 -
LeetCode 91 Decode Ways
原题:(频率3) A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded message containing digits, deter原创 2017-10-23 14:01:03 · 130 阅读 · 0 评论 -
LeetCode 93 Restore IP Addresses
原题:(频率4) Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example: Given "25525511135", return ["255.255.11.135", "255.2原创 2017-10-23 14:18:54 · 143 阅读 · 0 评论 -
LeetCode 7&9 Reverse Integer & Palindrome Number
这两题都很简单,就是反转数字,基本代码是一样的,只是回文最后需要判断一下,直接上代码 第七题 class Solution { public int reverse(int x) { long res = 0; while(x != 0){ res = res*10 + x%10; x = x/10;原创 2018-01-10 01:30:20 · 135 阅读 · 0 评论 -
LeetCode 2 Add Two Numbers
原题: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and原创 2018-01-10 01:09:09 · 131 阅读 · 0 评论 -
LeetCode 88 Merge Sorted Array
原题: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) to原创 2018-01-15 18:03:16 · 134 阅读 · 0 评论 -
LeetCode 86 Partition List
原题: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in原创 2018-01-15 17:42:32 · 132 阅读 · 0 评论 -
LeetCode 75 荷兰三色旗
原题: Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we wil原创 2017-10-09 15:54:15 · 368 阅读 · 0 评论 -
LeetCode 74 Search a 2D Matrix
原题:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row ...原创 2017-10-09 14:49:16 · 178 阅读 · 0 评论 -
LeetCode 66 Plus One
原题: Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not contain any leading zero, except the number 0 itself. T原创 2018-01-15 14:15:50 · 138 阅读 · 0 评论 -
LeetCode 70. Climbing Stairs
原题: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n wil原创 2018-01-14 17:34:20 · 134 阅读 · 0 评论 -
LeetCode 48 Rotate Image
LeetCode 48 Rotate Image You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-pla原创 2017-10-13 14:01:44 · 174 阅读 · 0 评论 -
LeetCode 120
原题: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following tria原创 2017-10-10 19:19:23 · 128 阅读 · 0 评论 -
LeetCode 58 Length of Last Word
原题:(频率1) Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.原创 2017-10-19 14:34:21 · 117 阅读 · 0 评论 -
LeetCode 38 Count and Say
原题:(频率2) Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Given n = 3, You shoul原创 2017-10-19 14:28:42 · 133 阅读 · 0 评论 -
LeetCode 28 Implement strStr()
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Given n = 3, You shoul原创 2017-10-19 14:19:39 · 147 阅读 · 0 评论 -
LeetCode 20. Valid Parentheses
原题:(频率5) Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}原创 2017-10-19 14:11:55 · 124 阅读 · 0 评论 -
LeetCode 14.Longest Common Prefix
原题:(频率2) Write a function to find the longest common prefix string amongst an array of strings. 题意:此题题意描述有问题,其实只是求最长前缀原创 2017-10-19 14:07:50 · 139 阅读 · 0 评论 -
LeetCode 106
原题: Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.原创 2017-10-10 14:24:05 · 316 阅读 · 0 评论 -
LeetCode 105
原题: Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.原创 2017-10-10 13:30:40 · 225 阅读 · 0 评论 -
LeetCode 81和33
原题:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Write a function to determine if a given target is in ...原创 2017-10-09 23:29:02 · 245 阅读 · 0 评论 -
LeetCode 73
原题: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. 题意: 给一个矩阵,如果某点的值为0,那么把它所在的行原创 2017-10-09 13:35:25 · 232 阅读 · 0 评论 -
LeetCode 125 Valid Palindrome
原题:(频率5) Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a原创 2017-10-19 14:39:24 · 149 阅读 · 0 评论 -
LeetCode 3 Longest Substring Without Repeating Characters
原题:(频率2) Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "原创 2017-10-19 14:52:55 · 145 阅读 · 0 评论 -
LeetCode 39,40,46,47,78,90 回溯法专题
回溯法介绍: 回溯法对任一解的生成,一般都采用逐步扩大解的方式。每前进一步,都试图在当前部分解的基础上扩大该部分解。它在问题的状态空间树中,从开始结点(根结点)出发,以深度优先搜索整个状态空间。这个开始结点成为活结点,同时也成为当前的扩展结点。在当前扩展结点处,搜索向纵深方向移至一个新结点。这个新结点成为新的活结点,并成为当前扩展结点。如果在当前扩展结点处不能再向纵深方向移动,则当前扩展结点就成原创 2017-10-12 14:43:05 · 242 阅读 · 0 评论 -
LeetCode 34 Search for a Range
原题:(频率3) Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime complex原创 2017-10-12 13:11:32 · 167 阅读 · 0 评论 -
LeetCode 33 Search in Rotated Sorted Array
原题:(频率3) Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7原创 2017-10-12 12:48:39 · 135 阅读 · 0 评论 -
LeetCode 31
原题:(频率2) Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not pos原创 2017-10-12 12:34:22 · 137 阅读 · 0 评论 -
LeetCode 16
原题: 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. You may as原创 2017-10-12 11:18:58 · 108 阅读 · 0 评论 -
leetCode 11
原题: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 endpoints of line i is at (i, ai) and (i, 0). Find t...原创 2017-10-12 10:43:25 · 181 阅读 · 0 评论 -
LeetCode 12 Integer to Roman
原题:(频率4) Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 题意:把Inte原创 2017-10-19 15:53:31 · 139 阅读 · 0 评论