import java.util.ArrayList;
public class SolutionA { public boolean judgeCircle(String moves) { ArrayList<Character> u=new ArrayList<>(); ArrayList<Character> d=new ArrayList<>(); ArrayList<Character> l=new ArrayList<>(); ArrayList<Character> r=new ArrayList<>(); for (int i=0;i<moves.length();i++) { char a=moves.charAt(i); if (a=='U') { u.add(a); }else if(a=='L') { l.add(a); }else if(a=='D') { d.add(a); }else if(a=='R') { r.add(a); } } if(u.size()==d.size()&&l.size()==r.size()) { return true; }else { return false; } } }