interesting algorithm questions solved in javascript