Wissen Technology Interview Question
Java DevelopersCountry: India
Interview Type: Phone Interview
All the above answers are changing while loop while the question forbids to do so. I would rather implement iterable interface and override its next() method to increment by 2 (obviously after length check) insteead of incrementing by 1 which is the standard implementation..
How to do so? Here you go..
https://stackoverflow.com/questions/5849154/can-we-write-our-own-iterator-in-java?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
just adding two lines
- Popeye May 14, 2018