clean-up: added annotations for task difficulty, type etc.
added javadoc
added missing tests and covered one of the edge cases
redesigned algorithm (still the same time complexity)
replaced linear search with binary search; replaced longs with ints for better performance