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, 20961 Search Bots | 49 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 714 Views, 20961 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, 20961 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 Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
- Algorithm Interview: String Compression
- Daily Interview Question: Edit Distance
- Detect Linked List Cycle
- Algorithm Interview: Level Order Traversal of Binary Tree
- Daily Interview Puzzle: Minimum Size Subarray Sum
- Reverse a Linked List
- Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
- Daily Interview Problem: Sort Colors
- Daily Interview Problem: Minimum Removals for Valid Parenthesis
©2006~2024 SteakOverCooked - 0.00707 Seconds(s) - 2769.253 KB/s - 24 Online Memory: 493.75 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="index, 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 !