[DAY8]Fraudulent Activity Notifications

Sherlock Chiou
1 min readOct 14, 2019

--

https://www.hackerrank.com/…/fraudulent-activity-no…/problem

Solution 1: Traverse through the array and check if we need to make alert. But we need to keep sorting in order to find the median. If we use the bubble sort algorithm, the time complexity would be as high as O(N³).

Solution 2: Use counting sort algorithm and the time complexity can be down to O(1) when doing sorting to find median . There is a more simple way to implement which expanse to remove. Use queue to record the expanse and dequeue would make sure we remove the oldest expanse.

--

--

Sherlock Chiou
Sherlock Chiou

Written by Sherlock Chiou

Be Effective and Optimize for Learning

No responses yet