content: class Solution {
      // Function to add two strings.
      private ArrayList<Integer> addStrings(ArrayList<Integer> num1, ArrayList<Integer> num2) {
          ArrayList<Integer> ans = new ArrayList<>();
          int carry = 0;
          
          for (int i = 0; i < num1.size() || i < num2.size(); ++i) {
              // If num2 is shorter than num1 or vice versa, use 0 as the current digit.
              int digit1 = i < num1.size() ? num1.get(i) : 0;
              int digit2 = i < num2.size() ? num2.get(i) : 0;
              
              // Add current digits of both numbers.
              int sum = digit1 + digit2 + carry;
              // Set carry equal to the tens place digit of sum.
              carry = sum / 10;
              // Append the ones place digit of sum to answer.
              ans.add(sum % 10);
          }
          
          if (carry != 0) {
              ans.add(carry);
          }
          return ans;
      }
      
      // Multiply the current digit of secondNumber with firstNumber.
      ArrayList<Integer> multiplyOneDigit(StringBuilder firstNumber, char secondNumberDigit, int numZeros) {
          // Insert zeros at the beginning based on the current digit's place.
          ArrayList<Integer> currentResult = new ArrayList<>();
          for (int i = 0; i < numZeros; ++i) {
              currentResult.add(0);
          }
          
          int carry = 0;
  
          // Multiply firstNumber with the current digit of secondNumber.
          for (int i = 0; i < firstNumber.length(); ++i) {
              char firstNumberDigit = firstNumber.charAt(i);
              int multiplication = (secondNumberDigit - '0') * (firstNumberDigit - '0') + carry;
              // Set carry equal to the tens place digit of multiplication.
              carry = multiplication / 10;
              // Append last digit to the current result.
              currentResult.add(multiplication % 10);
          }
  
          if (carry != 0) {
              currentResult.add(carry);
          }
          return currentResult;
      }
      
      public String multiply(String num1, String num2) {
          if (num1.equals("0") || num2.equals("0")) {
              return "0";
          }
          
          StringBuilder firstNumber = new StringBuilder(num1);
          StringBuilder secondNumber = new StringBuilder(num2);
          
          // Reverse both the numbers.
          firstNumber.reverse();
          secondNumber.reverse();
          
          // To store the multiplication result of each digit of secondNumber with firstNumber.
          int N = firstNumber.length() + secondNumber.length();
          ArrayList<Integer> ans = new ArrayList<>();
          for (int i = 0; i < N; ++i) {
              ans.add(0);
          }
          
          // For each digit in secondNumber, multipy the digit by firstNumber and
          // add the multiplication result to ans.
          for (int i = 0; i < secondNumber.length(); ++i) {
              // Add the current result to final ans.
              ans = addStrings(multiplyOneDigit(firstNumber, secondNumber.charAt(i), i), ans);
          }
          
          // Pop excess 0 from the rear of ans.
          if (ans.get(ans.size() - 1) == 0) {
              ans.remove(ans.size() - 1);
          }
          
          // Ans is in the reversed order.
          // Copy it in reverse order to get the final ans.
          StringBuilder answer = new StringBuilder();
          
          for (int i = ans.size() - 1; i >= 0; --i) {
              answer.append(ans.get(i));
          }
          
          return answer.toString();
      }
  }