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 | 218 Views, 23888 Search Bots | 58 Words
| Browse | Archive
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 218 Views, 23888 Search Bots | 58 Words
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
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 | 218 Views, 23888 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)
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Related Articles
- Spreadsheet Columns
- Daily Interview Problem: Spiral Traversal of Grid
- Most Frequent Subtree Sum
- Generate All IP Addresses
- Invert a Binary Tree
- New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
- Two Tricks of Delphi
- Top K Frequent words
- Find Pythagorean Triplets
- First and Last Indices of an Element in a Sorted Array
©2006~2024 SteakOverCooked - 0.01043 Seconds(s) - 1811.863 KB/s - 50 Online
Memory: 492.52 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" />
![](/images/top.jpg)
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !