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 | 714 Views, 20967 Search Bots | 49 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 714 Views, 20967 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 | 714 Views, 20967 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
- Find Pythagorean Triplets
- Number of Ways to Climb Stairs
- [Daily Problem] Move Zeros
- Daily Interview Question: Edit Distance
- Daily Interview Problem: Merge K Sorted Linked Lists
- [Daily Problem] Angles of a Clock
- Daily Interview Problem: Decode String
- Daily Interview Problem: 3 Sum
- Two-Sum
- Algorithm Interview: Maximum Path Sum in Binary Tree
©2006~2024 SteakOverCooked - 0.00748 Seconds(s) - 2533.424 KB/s - 9 Online Memory: 492.36 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 !