Ad
  • Default User Avatar

    I had a similar first approach before moving on to my final solution. One thing that could be imporved on in this solution is to use the Java StringBuilder instead of String concatenation via the + operator, as the + operator causes the loop to actually have an O(N^2) runtime.