-1
package practise;

import java.util.Arrays;
import java.util.Scanner;

public class testcode {
public static void main(String[] args) {
    Scanner n1 = new Scanner(System.in);
    int n = n1.nextInt();
    int count =0;
    for(int i = 0; i < n; i++)
    {
        String s = n1.nextLine();
        String t = n1.nextLine();
        char charar1[] = s.toCharArray();
        Arrays.sort(charar1);
        char charar2[] = t.toCharArray();
        Arrays.sort(charar2);
        for(int j = 0; j <= 100; j++)
        {
            if(charar1[j] != charar2[j])
            {
                count++;
            }
        }
        System.out.println(charar1);
        System.out.println(charar2);
    }
    System.out.println(count);
}

}

and the prolem statement is Bob and Khatu both love the string. Bob has a string S and Khatu has a string T. They want to make both string S and T to anagrams of each other. Khatu can apply two operations to convert string T to anagram of string S which are given below: 1.) Delete one character from the string T. 2.) Add one character from the string S.

Khatu can apply above both operation as many times he want. Find the minimum number of operations required to convert string T so that both T and S will become anagram of each other.

Input:

First line of input contains number of test cases T. Each test case contains two lines. First line contains string S and second line contains string T.

Output:

For each test case print the minimum number of operations required to convert string T to anagram of string S.

Constraints:

1 ≤ T ≤ 10 1 ≤ |S|,|T| ≤ 105

  • 1
    Your exception message says line 48 of TestClass, which is not the class shown in your question. Please update your question with the actual code and indicate which line the exception refers to. – tgdavies Nov 22 '20 at 04:16
  • Okay, so what is your *question*? – Karl Knechtel Nov 22 '20 at 05:45

1 Answers1

0

You're asuming both strings are the same length as 100, you must iterate over the length of the array, if they have the same length