File: root - text - article - 2020 - 01 - max-and-min-with-limited-comparisons.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 384 Views, 26885 Search Bots | 58 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 384 Views, 26885 Search Bots | 58 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by Microsoft:
Given a list of numbers of size n, where n is greater than 3, find the maximum and minimum of the list using less than 2 * (n - 1) comparisons.
Here's a start:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 384 Views, 26885 Search Bots | 58 Words Given a list of numbers of size n, where n is greater than 3, find the maximum and minimum of the list using less than 2 * (n - 1) comparisons.
Here's a start:
def find_min_max(nums):
# Fill this in.
print find_min_max([3, 5, 1, 2, 4, 8])
# (1, 8)
Related Articles
- Most Frequent Subtree Sum
- Print a tree level-by-level, with line-breaks
- Daily Interview Problem: Jump to the End
- Find Missing Numbers in an Array
- [Daily Problem] Validate Balanced Parentheses
- Algorithm Interview: Smallest Number that is not a Sum of a Subset of List
- Daily Interview Problem: Count Number of Unival Subtrees
- Daily Interview Problem: Contiguous Subarray with Maximum Sum
- [Daily Problem] Course Prerequisites
- Number of Ways to Climb Stairs
©2006~2024 SteakOverCooked - 0.01191 Seconds(s) - 4487.463 KB/s - 79 Online Memory: 529.06 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !