One solution to the above problem is to use an inbuilt string class of java that is mutable i.e. StringBuilder, which cuts/appends the string in O(1) time. Therefore, java code using StringBuilder class with time complexity O(n) is as follows: import java.util.*; public class Main {...