But I'm kind of like lost in terms of how to write a permutation right now. I'm still devising a strategy for finding the permutations. we'll see if the queue exists, then start with the index. So what do I place it in the queue? So, the gap, the string itself is a permutation of that character, so let's start with the queue with value of the string, and string of. So we have to take one, and all the different, all the different permutations, except for the character, big one and all the different permutations except for the character, so when breadth first search is involved, we have to have a queue and then pop information from a queue and then put them in order. I think breadth first search has the option to kind of like find out, okay, so it's not really depth first search. And if I do it recursively it's actually a graph where the A is connected to B. Okay, I think so, let's try to do it recursively. So we have to find out the permutations of that. And then I have to select B and find all permutations of the rest of the string. So after selecting a, I have to find out all combinations of the rest, that's B. So permutations, I'm trying to recall I'm trying to see the depth first search or the breadth first search will be the most suitable one for the permutation. Like it has tools and data tools can provide permutations and. So how do I get the permutations of a string? Usually, like there are higher order functions in Python available. Let me write an outline and then define it. it's either depth first search or breadth first search, I'm trying to use one of them. There is actually graph algorithms to do the permutations like depth first search. Okay, so permutations are like take each string and then take characters of each string and rearrange it in a different order. But let's, I can try the first approach of like finding all permutations for. Are there any other approaches like perhaps using dynamic programming? Maybe, but I'm not sure about that. And when you do one permutation at a time, find out if the permutation is present in string s2. The guts of the problem is finding all permutations of the string s1. Yeah, so it's actually like two problems in one.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |