To the Top
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 | 171 Views, 22645 Search Bots | 58 Words

Subscribe to Feed Burner | 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:


def find_min_max(nums):
# Fill this in.

print find_min_max([3, 5, 1, 2, 4, 8])
# (1, 8)
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 171 Views, 22645 Search Bots | 58 Words Subscribe to Feed Burner

Related Articles

  1. Longest Substring Without Repeating Characters
  2. Find Missing Numbers in an Array
  3. Reverse a Linked List
  4. How to Play WAV music under DOS?
  5. Kaprekar
  6. Batch Programming in XP
  7. Daily Interview Problem: Distribute Bonuses
  8. Daily Interview Problem: Contiguous Subarray with Maximum Sum
  9. Daily Interview Problem: Arithmetic Binary Tree
  10. [Daily Problem] Witness of The Tall People

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="index, follow">