Member-only story

Interview Question: Get matching and non-matching characters in a string

Crystal X
3 min readMay 4, 2023

--

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:-

  1. Define a string, string.
  2. Define an empty array, matching_char.
  3. Create a for loop in the range of the length of string, with the iterator as i.
  4. 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.
  5. Convert the array, matching_char, to a set.

--

--

Crystal X
Crystal X

Written by Crystal X

I have over five decades experience in the world of work, being in fast food, the military, business, non-profits, and the healthcare sector.

No responses yet