一道题目- Find the smallest range that includes at least one number from each of the k lists
2016-12-02 21:13
836 查看
You have k lists of sorted integers. Find the smallest range that includes at least one number from each of the k lists.
For example,
List 1: [4, 10, 15, 24, 26]
List 2: [0, 9, 12, 20]
List 3: [5, 18, 22, 30]
The smallest range here would be [20, 24] as it contains 24 from list 1, 20 from list 2, and 22 from list 3.
https://www.careercup.com/page?sort=votes
我的思路是先取最小的triple,然后最小的那个,增加。迭代。
For example,
List 1: [4, 10, 15, 24, 26]
List 2: [0, 9, 12, 20]
List 3: [5, 18, 22, 30]
The smallest range here would be [20, 24] as it contains 24 from list 1, 20 from list 2, and 22 from list 3.
https://www.careercup.com/page?sort=votes
我的思路是先取最小的triple,然后最小的那个,增加。迭代。
相关文章推荐
- CareerCup Find the smallest range that includes at least one number from each of the k sorted lists.
- leetcode :Find the contiguous subarray within an array (containing at least one number) which has th
- 题目描述 Given n points on a 2D plane, find the maximum number of points that lie on the same straight
- Topology activation failed. Each partition must have at least one index component from the previous topology in the new topology, in the same host.
- xcode4 上传app 报错At least one of the following architecture(s) must be present :armv6
- iPhone/iPod Touch: application executable is missing a required architecture. At least one of the fo
- Neither the JAVA_HOME nor the JRE_HOME environment variable is defined ;At least one of these environment variable is needed to run this program
- xcode 4.2 itunes上传时 At least one of the following architecture(s) must be present: armv6 (-19033)
- ERROR 1227 (42000): Access denied; you need (at least one of) the PROCESS privilege(s) for this oper
- xcode 4.2 itunes上传时 At least one of the following architecture(s) must be present: armv6 (-19033)
- Add the feature that can kill process at begining of each case
- Microsoft SQL Server 2008 R2 XML处理 One solution is to increase the number of characters retrieved from the server for XML data.
- Linux下tomcat启动Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of
- Increase the ordinal number at the beginning of each line
- Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
- tomcat启动报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable
- ERROR 1227 (42000): Access denied; you need (at least one of) the PROCESS privilege(s) for this oper
- CareerCup Find at-least one triplet such that A[n-1] >= A[n] <= A[n+1].
- from given array of n elements find the maximum element for each consecutive sub-array of k elements.
- 解决itunesconnect上传时"at least one of the following architecture(s) must be present:armv6"问题