• + 0 comments

    Find no answer without solving:

        ArrayList<Character> s = new ArrayList<Character>();
        ArrayList<Character> o = new ArrayList<Character>();
        int l = w.length();
        for(int i = 0; i < l; i++){
            s.add(w.charAt(i));
        }
        o = (ArrayList<Character>)s.clone();
        Collections.sort(s, Collections.reverseOrder());
    
        if(o.equals(s)){
            return "no answer";
        }
    

    Then solve using lexicographical permutation algorithm