Member-only story

Interview question: Delete repeated elements in an integer array

Crystal X
2 min readMay 25, 2023

--

In the last blog post I made concerning Python interview questions, I discussed how to get matching elements of an integer array. That blog post can be read here:- https://medium.com/@tracyrenee61/interview-question-get-matching-elements-of-an-integer-array-5be7f5be89d4

In this blog post, I intend to modify the algorithm used above to delete repeated elements in an array. The solution to this problem is a little tricky. Although it seems like a simple thing to do, the key component in the solution is to make a copy of the list of integers, otherwise the algorithm will not work.

The psuedocode for the algorithm to delete repeated elements in an integer array is:-

  1. Define the function, del_element, which takes a list as an input, lst.
  2. Within the function, define the variable, len_lst, which is the length of the list, lst.
  3. Within the function, defined the variable, which is a copy of the list, lst.
  4. Within the function, create a for loop that iterates through the range of the length of list at an increment of 1. The iterator is the variable, i.
  5. Within the for loop, create a second for loop that iterates through the range of i+1 to the length of the list at an increment of 1. The iterator…

--

--

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