characters from and then see if occurs howeverthere is difficulty with this approach when generating all possible strings from there are possible first charactersn- possible characters for the second positionn for the thirdand so on the total number of candidate strings is ( ( which is nalthough some of the strings may be duplicatesthe program cannot know this ahead of time and so it will still generate ndifferent strings it turns out that ngrows even faster than as gets large in factif were characters longthere would be possible candidate strings if we processed one possibility every secondit would still take us years to go through the entire list this is probably not going to be good solution solution count and compare our final solution to the anagram problem takes advantage of the fact that any two anagrams will have the same number of 'sthe same number of 'sthe same number of 'sand so on in order to decide whether two strings are anagramswe will first count the number of times each character occurs since there are possible characterswe can use list of countersone for each possible character each time we see particular characterwe will increment the counter at that position in the endif the two lists of counters are identicalthe strings must be anagrams def anagram_solution ( ) [ [ for in range(len( ))pos ord( [ ]ord(' ' [posc [pos for in range(len( ))pos ord( [ ]ord(' ' [posc [pos still_ok true while and still_okif [ = [ ] elsestill_ok false return still_ok print(anagram_solution ('apple','pleap')againthe solution has number of iterations howeverunlike the first solutionnone of them are nested the first two iterations used to count the characters are both based on the third iterationcomparing the two lists of countsalways takes steps since there are possible algorithm analysis