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.
In reply to Re: add missing elements and remove duplicates....and some more questions.
by Anonymous Monk
in thread add missing elements and remove duplicates....and some more questions.
by pritesh_ugrankar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |