Amazon Interview Question for SDE1s
- 0of 0 votes
"Good Range"- mitswami25 May 29, 2019 in United States
There is a number space given from 1 to N. And there are M queries followed by that. In each query, we were given a number between 1 to N (both inclusive). We add these number one by one into a set.
Good range: A range in which there is exactly one element present from the set.
For each query, we need to find the good ranges. We need to return the sum of boundry of all good ranges.
First line will take two integer for input N and M.
Then following M lines would be numbers between 1 and N (both inclusive).
Following M lines contains sum of boudaries of good ranges.
Range can consist of single element and represented as (x-x) where boundary sum will be x+x.
step-1) set: 2
good range: (1-10)
step-2) set: 2 5
good range: (1-4), (3-10)
step-3) set: 2 5 7
good range: (1-4), (3-6), (6-10)
step-4) set: 2 5 7 9
good range: (1-4), (3-6), (6-8), (8-10)
| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding
Interview Type: Phone Interview
Open Chat in New Window