Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

CLEANUP - Editorial

$
0
0

PROBLEM LINKS

Practice
Contest

DIFFICULTY

EASY

EXPLANATION

No real tricks here. An easy approach is to create a boolean array b[] of size n where item b[i] is true if and only if i does not appear in the input list. Make two passes through the array, each time keeping track of the number of "true" items seen so far. When an entry i is hit such that b[i] is true, output i if and only if the number of true items seen so far is odd/even depending on whether it is the first/second pass.


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>