Accepted in first attempt(JAVA Implementation)