My issue
Can anyone explain in this case
4 1 0
RRDU
output should be YES, but in testcase it is mentioned as NO
My code
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
int x=sc.nextInt();
int y=sc.nextInt();
String s=sc.next();
int xi=0,yi=0;
int remainingMoves=0,manhattanDistance=0;
for(int i=0;i<s.length();i++)
{
char ch=s.charAt(i);
if(ch=='R')
xi++;
else if(ch=='D')
yi--;
else if(ch=='L')
xi--;
else if(ch=='U')
yi++;
}
if (x-xi <=n || y-yi<=n)
System.out.println("YES");
else
System.out.println("NO");
}
}
}
Problem Link: FightBots Practice Coding Problem