Adamant kid java Java Avg part 3
An adamant kid keeps on repeating the stuff he wants. Like if the kid wants chocolate he keeps repeating "chocolate". Given the stuff the child is demanding the program must print if the character in two given positions X, Y is same or not by printing YES or NO.
import java.util.*;
public class Hello {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String a=sc.nextLine();
int b=sc.nextInt();
int c=sc.nextInt();
if((c/(a.length()))>=a.length())
{
c=(c/a.length())/a.length()-1;
}
else
c=c/a.length();
if(a.charAt(b)==a.charAt(c))
System.out.print("YES");
else
System.out.print("NO");
}
}
Comments
Post a Comment