Hint: Recall that concatenating two strings in Java takes time proportional to the sum of their lengths.public static String method1(int N) { String s = ""; for (int i = 0; i < N; i++) s = s + "x"; return s; }
2.
In this exercise, you will develop a quadratic-time algorithm for the 3-sum problem.
When we ask you to design an algorithm, give a crisp and concise
English description of your algorithm - don't write Java code.
Hint: start by checking whether a[0] + a[N-1] is smaller than, greater than, or equal to x.
Hint: Use the result from (a). You can assume the array is sorted since sorting the array can be done in quadratic (and even linearithmic) time.