摘要: Given an unsorted array of integers, find the length of longest increasing subsequence. 阅读全文
posted @ 2019-06-26 16:18 yjxyy 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Given an array *nums* containing *n* + 1 integers where each integer is between 1 and *n* (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one. 阅读全文
posted @ 2019-06-26 16:07 yjxyy 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer *n*, find the least number of perfect square numbers (for example, `1, 4, 9, 16, ...`) which sum to *n*. 阅读全文
posted @ 2019-06-26 16:03 yjxyy 阅读(500) 评论(0) 推荐(0) 编辑
摘要: Given a string containing just the characters `'('` and `')'`, find the length of the longest valid (well-formed) parentheses substring. 阅读全文
posted @ 2019-06-26 15:59 yjxyy 阅读(99) 评论(0) 推荐(0) 编辑
摘要: Merge *k* sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 阅读全文
posted @ 2019-06-26 15:50 yjxyy 阅读(131) 评论(0) 推荐(0) 编辑
摘要: There are two sorted arrays **nums1** and **nums2** of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 阅读全文
posted @ 2019-06-26 15:02 yjxyy 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 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. 阅读全文
posted @ 2019-06-26 14:39 yjxyy 阅读(339) 评论(0) 推荐(0) 编辑
摘要: Given a **non-empty** array containing **only positive integers**, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. 阅读全文
posted @ 2019-06-26 14:05 yjxyy 阅读(982) 评论(0) 推荐(0) 编辑
摘要: Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers `(h, k)`, where `h` is the height of the person and `k` is the number of people in front of this person who have a height greater than or equal to `h`. Write an algorithm to reconstruct the queue. 阅读全文
posted @ 2019-06-26 14:00 yjxyy 阅读(114) 评论(0) 推荐(0) 编辑
摘要: Given an encoded string, return it's decoded string. 阅读全文
posted @ 2019-06-26 13:49 yjxyy 阅读(166) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty array of integers, return the **k** most frequent elements. 阅读全文
posted @ 2019-06-26 13:37 yjxyy 阅读(385) 评论(0) 推荐(0) 编辑
摘要: Given a non negative integer number **num**. For every numbers **i** in the range **0 ≤ i ≤ num** calculate the number of 1's in their binary representation and return them as an array. 阅读全文
posted @ 2019-06-26 11:43 yjxyy 阅读(162) 评论(0) 推荐(0) 编辑
摘要: You are given coins of different denominations and a total amount of money *amount*. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return `-1`. 阅读全文
posted @ 2019-06-26 11:29 yjxyy 阅读(230) 评论(0) 推荐(0) 编辑
摘要: Given an array `nums` of *n* integers where *n* > 1, return an array `output` such that `output[i]` is equal to the product of all the elements of `nums` except `nums[i]`. 阅读全文
posted @ 2019-06-26 11:25 yjxyy 阅读(98) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. 阅读全文
posted @ 2019-06-26 11:20 yjxyy 阅读(171) 评论(0) 推荐(0) 编辑