Member-only story
Interview Question: Get matching and non-matching characters in a string
Any person who intends to be a Python developer will need to know basic programming techniques and how to develop algorithms. In addition, he is likely to need to demonstrate this ability in an interview for a role working with Python.
One interview question that is likely to come up is to get the matching characters from a string.
I carried out a bit of research and was not able to find any solutions to this particular question on stackoverflow or any other Python coding websites, so I wrote a small piece of code myself to solve this problem.
The psuedocode for this algorithm is:-
- Define a string, string.
- Define an empty array, matching_char.
- Create a for loop in the range of the length of string, with the iterator as i.
- Create a for loop in the first for loop of the length of string, with the iterator as j. In the second for loop, if i is less than j, and if the character i equals the character j then append the character to the array, matching_char, otherwise continue iterating through the loop.
- Convert the array, matching_char, to a set.