
文章平均质量分 61
lilibaobao89
这个作者很懒,什么都没留下…
展开
-
1762. Buildings With an Ocean View
【代码】1762. Buildings With an Ocean View。原创 2023-11-06 03:01:36 · 232 阅读 · 0 评论 -
1249. Minimum Remove to Make Valid Parentheses
【代码】1249. Minimum Remove to Make Valid Parentheses。原创 2023-11-06 02:26:51 · 232 阅读 · 0 评论 -
297. Serialize and Deserialize Binary Tree
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be...原创 2017-04-26 06:53:00 · 193 阅读 · 0 评论 -
38. Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as原创 2017-06-04 14:50:48 · 155 阅读 · 0 评论 -
124. Binary Tree Maximum Path Sum
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the larges原创 2017-06-19 12:53:22 · 166 阅读 · 0 评论 -
Convert a Binary Tree to Doubly Linked List
Given a Binary Tree (Bt), convert it to a Doubly Linked List(DLL). The left and right pointers in nodes are to be used as previous and next pointers respectively in converted DLL. The order of nod原创 2017-06-19 12:39:57 · 445 阅读 · 0 评论 -
152. Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the larges原创 2017-06-19 12:23:16 · 148 阅读 · 0 评论 -
377. Combination Sum IV
Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.Example:nums = [1, 2, 3]target = 4The pos原创 2017-06-19 12:19:12 · 164 阅读 · 0 评论 -
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 hold add原创 2017-06-19 11:53:00 · 179 阅读 · 0 评论 -
128. Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2,原创 2017-06-19 09:53:54 · 145 阅读 · 0 评论 -
Prime Number Combination Product
给一个质数数组,返回所有可能的product,顺序不管比如给 [2,3,5] 返回 [2,3,5,6,10,15,30]数组中的数如果有重复则需要去重,不允许用set。比如给 [2,2,2] 返回 [2,4,8],顺序不用管。public List combinePrimeProduct(int[] primes) { Arrays.sort原创 2017-06-19 07:43:53 · 343 阅读 · 0 评论 -
273. Integer to English Words
Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.For example,123 -> "One Hundred Twenty Three"12345 -> "Twelve Thousand Th原创 2017-04-27 05:25:29 · 396 阅读 · 0 评论 -
238. Product of Array Except Self
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(n).For原创 2017-05-17 13:23:24 · 173 阅读 · 0 评论 -
43. Multiply Strings
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 contains only digits原创 2017-06-19 05:36:45 · 261 阅读 · 0 评论 -
157. Read N Characters Given Read4
The API: int read4(char *buf) reads 4 characters at a time from a file.The return value is the actual number of characters read. For example, it returns 3 if there is only 3 characters left in the原创 2017-06-19 05:19:24 · 204 阅读 · 0 评论 -
71. Simplify Path
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to show corner cases.public class Solution {原创 2017-06-09 08:21:46 · 145 阅读 · 0 评论 -
13. Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.罗马数字有如下符号:基本字符IVXLCDM对应阿拉伯数字151050原创 2017-06-09 08:54:49 · 230 阅读 · 1 评论 -
494. Target Sum
You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.Find out原创 2017-06-11 08:28:01 · 141 阅读 · 0 评论 -
265. Paint House II
There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two原创 2017-06-15 08:31:39 · 326 阅读 · 0 评论 -
325. Maximum Size Subarray Sum Equals k
Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead.Note:The sum of the entire nums array is guaranteed to fit wi原创 2017-03-24 08:37:29 · 255 阅读 · 0 评论 -
209. Minimum Size Subarray Sum
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead.For example, given the原创 2017-06-15 05:25:31 · 306 阅读 · 0 评论 -
274. H-Index
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikipedia: "A原创 2017-06-14 14:54:33 · 247 阅读 · 0 评论 -
75. Sort Colors
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 will use the integers原创 2017-06-14 14:00:40 · 159 阅读 · 0 评论 -
15. 3Sum
Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not contain d原创 2017-04-14 07:07:55 · 158 阅读 · 0 评论 -
90. Subsets II
Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,2], a solutio原创 2017-06-14 12:38:25 · 160 阅读 · 0 评论 -
554. Brick Wall
There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different width. You want to draw a vertical line from the top to the原创 2017-06-13 12:42:41 · 154 阅读 · 0 评论 -
543. Diameter of Binary Tree
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may n原创 2017-06-12 14:32:10 · 144 阅读 · 0 评论 -
334. Increasing Triplet Subsequence
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should:Return true if there exists i, j, k such that arr[i] ar原创 2017-06-12 14:03:59 · 179 阅读 · 0 评论 -
286. Walls and Gates
You are given a m x n 2D grid initialized with these three possible values.-1 - A wall or an obstacle.0 - A gate.INF - Infinity means an empty room. We use the value 231 - 1 = 2147483647 to repr原创 2017-06-12 09:24:47 · 188 阅读 · 0 评论 -
269. Alien Dictionary
There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of non-empty words from the dictionary, where words are sorted le原创 2017-06-11 12:59:16 · 255 阅读 · 0 评论 -
398. Random Pick Index
Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.Note:The array size can原创 2017-06-11 08:37:38 · 149 阅读 · 0 评论 -
26. Remove Duplicates from Sorted Array i && ii
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with原创 2017-05-21 13:14:47 · 191 阅读 · 0 评论 -
K closest point to the origin
Give n points on 2-D plane, find the K closest points to origin13 public List KClosest(List input, int k) {14 List res = new LinkedList();15 PriorityQueue pq = new Priority原创 2017-06-19 03:20:02 · 840 阅读 · 0 评论 -
168. Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB public原创 2017-05-23 14:30:12 · 165 阅读 · 0 评论 -
146. LRU Cache
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 value (will always be positive) of the key i原创 2017-04-21 08:05:34 · 308 阅读 · 0 评论 -
341. Flatten Nested List Iterator
Given a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list -- whose elements may also be integers or other lists.Example 1:Given the li原创 2017-04-20 08:16:02 · 458 阅读 · 0 评论 -
23. Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity./** * Definition for singly-linked list. * public class ListNode { * int val; * Li原创 2017-04-15 07:10:16 · 193 阅读 · 0 评论 -
253. Meeting Rooms II
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference rooms required.For example,Given [[0, 30],[5,原创 2017-04-19 13:22:46 · 276 阅读 · 0 评论 -
161. One Edit Distance
Given two strings S and T, determine if they are both one edit distance apart.public class Solution { public boolean isOneEditDistance(String s, String t) { if(s == null || t == null原创 2017-04-19 06:56:32 · 213 阅读 · 0 评论 -
121. Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),原创 2017-04-19 02:15:33 · 623 阅读 · 0 评论