Problem: STRCOMPARE (Starters 18)
Dont know why,this code is giving NZEC error in codechef ide and another error in my intelliJ ideA…
package com.company;
import java.util.*;
public class Q1 {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int N;
int T = sc.nextInt();
while (T-- != 0) {
int c = 0;
N = sc.nextInt();
String A = sc.nextLine();
String B = sc.nextLine();
for (int i = 0; i < A.length(); i++) {
if (A.substring(i).compareTo(B.substring(i)) < 0)
++c;
}
System.out.println(c);
}
}
}
Once I remove the T loop and the N input,it works fine…but otherwise it shows ) in my ide…
package com.company;
import java.util.*;
public class Q1 {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int c = 0;
N = sc.nextInt();
String A = sc.nextLine();
String B = sc.nextLine();
for (int i = 0; i < A.length(); i++) {
if (A.substring(i).compareTo(B.substring(i)) < 0)
++c;
}
System.out.println(c);
}
}