Having a small array with some symbols like [\'^\',\'^\',\'>\',\'>\',\'+\',\'<\',\'<\'], how can I get all the different permutatio
Well the unique results issue is obviously going to be an efficiency killer as you going to have to check the results list each time you create a new permutation. As for the algorithm it will work in basically the same way as the other permutation algorithms, but your remove duplicates criteria will involve many more checks. If the size of the array is small efficiency should not be a large concern. Simply just loop through the answer array if value already found do not add to array. A way to speed up this checking process is to determine a way of sorting the answers array. For example ^ always comes before * which comes after ( Then you don't have to check the entire array each time. There are other methods of speeding this up but at the end of the day its still a pretty computationally expensive requirement. Since your array is small it should not matter at all unless you plan on doing this permutation ALOT