To the Top
File:  root - text - article - 2019 - 12 - running-median.txt.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 440 Views, 17176 Search Bots | 49 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Google:

You are given a stream of numbers. Compute the median for each new element .

Eg. Given [2, 1, 4, 7, 2, 0, 5], the algorithm should output [2, 1.5, 2, 3.0, 2, 2, 2]

Here's a starting point:


def running_median(stream):
# Fill this in.

running_median([2, 1, 4, 7, 2, 0, 5])
# 2 1.5 2 3.0 2 2.0 2
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 440 Views, 17176 Search Bots | 49 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Merge Overlapping Intervals
  2. Daily Interview Problem: Distribute Bonuses
  3. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  4. Daily Interview Puzzle: Ways to Traverse a Grid
  5. Daily Interview Problem: Reverse Words in a String
  6. Daily Interview Problem: 3 Sum
  7. Daily Interview Problem: Given two arrays, write a function to compute their intersection.
  8. Daily Interview Problem: Deepest Node in a Binary Tree
  9. Patterns for breaking down questions you haven
  10. Algorithm Interview: Level Order Traversal of Binary Tree

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="noindex, follow" />