Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static int MOD = 1000000007;

    // After writing solution, quick scan for:
    //   array out of bounds
    //   special cases e.g. n=1?
    //   npe, particularly in maps
    //
    // Big numbers arithmetic bugs:
    //   int overflow
    //   sorting, or taking max, after MOD
    void solve() throws IOException {
        int T = ri();
        for (int Ti = 0; Ti < T; Ti++) {
            int n = ri();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = ri();
            Deque<int[]> stack = new ArrayDeque<>();
            stack.addLast(new int[]{1});
            pw.println("1");
            for (int i = 1; i < n; i++) {
                if (a[i] == 1) {
                    int[] prev = stack.peekLast();
                    int[] curr = new int[prev.length+1];
                    System.arraycopy(prev, 0, curr, 0, prev.length);
                    curr[curr.length-1] = 1;
                    printArr(curr);
                    stack.addLast(curr);
                    continue;
                }
                while (!stack.isEmpty()) {
                    int[] prev = stack.removeLast();
                    if (a[i] == prev[prev.length-1] + 1) {
                        prev[prev.length-1]++;
                        printArr(prev);
                        stack.addLast(prev);
                        break;
                    } else {
                        continue;
                    }
                }
            }
        }
    }
    // IMPORTANT
    // DID YOU CHECK THE COMMON MISTAKES ABOVE?

    void printArr(int[] a) {
        pw.print(a[0]);
        for (int j = 1; j < a.length; j++) pw.print("." + a[j]);
        pw.println();
    }

    // Template code below

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        Main m = new... Complexity: