You can often use a stack or queue to avoid recursion. Implement
this algorithm for computing all permutations of a string str
without
recursion.
"|" + str
to the queue.Using this algorithm, implement a method
public static ArrayList<String> permutations(String s)
Draft: Your program should work for a string of length ≤ 2.