![]() If a question asks if strings are permutations of each other, it is asking if they have the. ![]() Depending on whether you start counting your permutations from 0 or 1, the answers is (2, 7, 8, 3, 9, 1, 5, 6, 0, 4) or (2, 7, 8, 3, 9, 1, 5, 6, 4, 0). A permutation is a different ordering of a strings characters. This is a skill, and it's one which is well worth developing as it helps you in the real world as well as in development. Permutes the range first, last) into the next permutation, where the set of all permutations is ordered lexicographically with respect to operator< or comp. Essentially, this finds the first element of the k-th permutation of S, and then recurses on the remaining string to find its first element. Hopefully, that should help you locate which part of that code has a problem, and what the problem is. Did it do what you expect? If so, move on to the next line. Think about what each line in the code should do before you execute it, and compare that to what it actually did when you use the "Step over" button to execute each line in turn. You can now run your code line-by-line (called "single stepping") and look at (or even change) variable contents as necessary (heck, you can even change the code and try again if you need to). Permutation in String - Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. A general formula for permutations is n (factorial of n) where n is the length of the string. Write an algorithm that takes an input string like abc, and prints out all possible permutations of the string. When it reaches the breakpoint, the debugger will stop, and hand control over to you. The task is to find all permutations (need not be different) of a given string. Put a breakpoint on the first line of the method, and run your app. ![]() ![]() Once you have an idea what might be going wrong, start using the debugger to find out why. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |