Solved Ladder in java