in reply to add missing elements and remove duplicates....and some more questions.
check each number with the preceding one
This seems to imply a sort-based approach was expected. But sort has the time complexity O(n log n) whereas your linear scan is O(n).
It's not uncommon to have TA-s generate teaching problems from random solutions, inadvertently ending up with a few non-solvable ones in the mix. And then, some teachers take it poorly when a student outsmarts them.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: add missing elements and remove duplicates....and some more questions.
by pritesh_ugrankar (Monk) on Apr 23, 2017 at 12:12 UTC | |
by Anonymous Monk on Apr 23, 2017 at 12:54 UTC |