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 | 695 Views, 19875 Search Bots | 49 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 695 Views, 19875 Search Bots | 49 Words
| 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:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 695 Views, 19875 Search Bots | 49 Words 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
Related Articles
- Daily Interview Puzzle: Intersection of Linked Lists
- Compare Version Numbers
- Algorithm Interview: Maximum Path Sum in Binary Tree
- Daily Interview Problem: Contiguous Subarray with Maximum Sum
- YES!!
- Daily Interview Puzzle: Ways to Traverse a Grid
- Algorithm Interview: Shifted String
- Algorithm Interview: Make the Largest Number
- Daily Interview Problem: Product of Array Except Self
- Plus One
©2006~2024 SteakOverCooked - 0.01209 Seconds(s) - 1579.444 KB/s - 19 Online Memory: 491.37 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 !