This approach is good or not i think this solution is in O(N)

static void moveAllXToEnd(String ques, String ans, int count) {
if (ques.length() == 0) {
for (int i = 0; i < count; i++) {
ans += ‘x’;
}
System.out.println(ans);
return;
}
char cc = ques.charAt(0);
String ros = ques.substring(1);
if (cc != ‘x’) {
ans += cc;
moveAllXToEnd(ros, ans, count);
} else {
moveAllXToEnd(ros, ans, count + 1);
}

}

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String ques = sc.next();
	moveAllXToEnd(ques, "", 0);
}

@nigamshubham1998,
You have got the correct answer. Any further doubts on this question?