File Download Coverage Percentage
Updated
Problem statement
A file has chunks numbered 1..totalChunks. Each inclusive interval records one completed download of every chunk in that range.
If requireTwice is false, return the integer percentage of chunks downloaded at least once, rounded down. If it is true, return 100 only when every chunk was downloaded at least twice; otherwise return 0.
Function
downloadCoveragePercent(totalChunks: int, intervals: int[][], requireTwice: boolean) → intExamples
Example 1
totalChunks = 5intervals = [[3,4]]requireTwice = falsereturn = 40Two of five chunks were downloaded.
Example 2
totalChunks = 5intervals = [[1,5],[1,5]]requireTwice = truereturn = 100Every chunk appears in both intervals.
Example 3
totalChunks = 5intervals = [[1,5],[2,5]]requireTwice = truereturn = 0Chunk 1 was downloaded only once.
Constraints
1 <= totalChunks <= 100000.0 <= intervals.length <= 100000.1 <= start <= end <= totalChunks.
More Persona Online Assessment questions
Similar questions at other companies
- Earliest Time to Schedule a MeetingMathWorks · OAMathWorks interview questions
- Earliest Meeting Start on a 24-Hour ClockIMC Trading · OAIMC Trading interview questions
- Earliest Time to Schedule a MeetingMicrosoft · OAMicrosoft interview questions
- Earliest Common Meeting StartVisa · OAVisa interview questions
- Smallest Most-Lit Street PositionHudson River Trading · OAHudson River Trading interview questions
- Most Visited Sprint MarkerChubb · OAChubb interview questions
- Earliest Common Meeting TimeZipRecruiter · OAZipRecruiter interview questions
- Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
- Majority Labels over Audio IntervalsNooks · PHONE SCREEN
- Zero Array Transformation IGoogle · ONSITE INTERVIEWGoogle interview questions