随笔分类 -  LeetCode

1 2 3 4 5 ··· 14 下一页
摘要:Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any 阅读全文
posted @ 2018-08-21 20:52 immjc 阅读(134) 评论(0) 推荐(0)
摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example: ip地址恢复 ip地址根据.分成4部分,每个部分都小于255. 编码 阅读全文
posted @ 2018-08-20 15:46 immjc 阅读(159) 评论(0) 推荐(0)
摘要:Given an integer n, return 1 - n in lexicographical order. For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9]. Please optimize your algori 阅读全文
posted @ 2018-08-20 10:25 immjc 阅读(154) 评论(0) 推荐(0)
摘要:Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two 阅读全文
posted @ 2018-08-13 10:51 immjc 阅读(120) 评论(0) 推荐(0)
摘要: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: [ 阅读全文
posted @ 2018-08-10 12:47 immjc 阅读(225) 评论(0) 推荐(0)
摘要:Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the s 阅读全文
posted @ 2018-08-06 21:03 immjc 阅读(134) 评论(0) 推荐(0)
摘要:Given an array of strings, group anagrams together. Example: Note: All inputs will be in lowercase. The order of your output does not matter. 给定一个字符串数 阅读全文
posted @ 2018-08-06 13:45 immjc 阅读(114) 评论(0) 推荐(0)
摘要:A sequence X_1, X_2, ..., X_n is fibonacci-like if: n >= 3 X_i + X_{i+1} = X_{i+2} for all i + 2 <= n Given a strictly increasing array A of positive 阅读全文
posted @ 2018-07-24 21:39 immjc 阅读(592) 评论(0) 推荐(0)
摘要: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 following seque 阅读全文
posted @ 2018-07-20 15:27 immjc 阅读(112) 评论(0) 推荐(0)
摘要: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 following seque 阅读全文
posted @ 2018-07-20 15:27 immjc 阅读(90) 评论(0) 推荐(0)
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib 阅读全文
posted @ 2018-07-20 12:35 immjc 阅读(130) 评论(0) 推荐(0)
摘要:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Example 2: 最长回文字串 回文字符串 阅读全文
posted @ 2018-07-12 20:33 immjc 阅读(157) 评论(0) 推荐(0)
摘要:Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If the 阅读全文
posted @ 2018-07-12 18:11 immjc 阅读(117) 评论(0) 推荐(0)
摘要:Given a list of non negative integers, arrange them such that they form the largest number. Example 1: Input: [10,2] Output: "210" Example 2: Input: [ 阅读全文
posted @ 2018-07-12 16:38 immjc 阅读(117) 评论(0) 推荐(0)
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the 阅读全文
posted @ 2018-06-19 22:06 immjc 阅读(110) 评论(0) 推荐(0)
摘要:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. Note: The algorithm should run in linear time and in O(1) spa 阅读全文
posted @ 2018-06-08 22:27 immjc 阅读(136) 评论(0) 推荐(0)
摘要:Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string. Example 1: Note 阅读全文
posted @ 2018-06-07 10:13 immjc 阅读(126) 评论(0) 推荐(0)
摘要:We are to write the letters of a given string S, from left to right into lines. Each line has maximum width 100 units, and if writing a letter would c 阅读全文
posted @ 2018-06-07 09:43 immjc 阅读(147) 评论(0) 推荐(0)
摘要:International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a"maps to ".-", "b" maps 阅读全文
posted @ 2018-06-07 09:29 immjc 阅读(133) 评论(0) 推荐(0)
摘要:A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com 阅读全文
posted @ 2018-06-07 09:15 immjc 阅读(191) 评论(0) 推荐(0)

1 2 3 4 5 ··· 14 下一页