Problem Statement:
| maze |
Solution Code in java:
import java.io.BufferedReader;
import java.io.InputStreamReader;
class TestEmaze {
public static void main(String args[] ) throws Exception {
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
String s= br.readLine();
int x=0, y=0;
if(s.length()>=1 && s.length()<=200){
for(int i=0;i<s.length();i++){
char c= s.charAt(i);
switch (c)
{
case 'L': x=x-1;
break;
case 'R': x=x+1;
break;
case 'U': y=y+1;
break;
case 'D': y=y-1;
break;
}
}
System.out.println(x + " " +y);
}
}
}
Hello Everyone, on this website you will get programming tutorials and projects so please follow us on our social media and subscribe to your feed. For any query, doubts please comment below. You can also react to the post using emoji.


0 Comments