Algorithm & Data Structure for Programming Contest in JavaScript