MockQuestions

Software Developer Mock Interview

Question 16 of 30 for our Software Developer Mock Interview

Software Developer was updated by on August 31st, 2021. Learn more here.

Question 16 of 30

Explain how duplicates are removed from an array without using a library?

"Having worked at many levels using arrays and class libraries, this is a pretty straightforward answer. If your input array contains multiple duplicates, this may result in many temporary arrays, some of which may not be needed. With this restriction in mind, I typically figure out how to minimize both memory and hardware requirements. When I need to delete an array using a more defined descriptive logic, the approach I take here is to find duplicate elements in a given array, then run an outer loop to 0 to size. As a next step in the process, I run another inner loop to find the first duplicate using another nested loop. To take it further, inside the inner loop, I also check for duplicate elements. If I find one, then I delete the array element."

Next Question

How to Answer: Explain how duplicates are removed from an array without using a library?

Advice and answer examples written specifically for a Software Developer job interview.

  • 16. Explain how duplicates are removed from an array without using a library?

      How to Answer

      If we look at the core of this question, it has to do with an array not finding duplicates. The goal here is to remove duplicates from an integer array without using any collection API class libraries. Several levels of interview questions will come up to test your knowledge of basic to complex problem-solving solutions. This one sits somewhere in the middle of the pack. When an interviewer asks whether or not you need a loop or recursion (depending on your skill level), they are asking the order in which elements are inserted in a Set. Answering with something like 'An array is a static, fixed-length structure that cannot change its length' is probably something that will tell the interviewer that you have a solid understanding of how deleting an array works.

      Written by Tom Dushaj on August 31st, 2021

      1st Answer Example

      "Having worked at many levels using arrays and class libraries, this is a pretty straightforward answer. If your input array contains multiple duplicates, this may result in many temporary arrays, some of which may not be needed. With this restriction in mind, I typically figure out how to minimize both memory and hardware requirements. When I need to delete an array using a more defined descriptive logic, the approach I take here is to find duplicate elements in a given array, then run an outer loop to 0 to size. As a next step in the process, I run another inner loop to find the first duplicate using another nested loop. To take it further, inside the inner loop, I also check for duplicate elements. If I find one, then I delete the array element."

      Written by Tom Dushaj on August 31st, 2021

      2nd Answer Example

      "I have found there are a few different approaches to removing duplicate elements. There are cases where I need to take one approach if I am not allowed to use collection API's. For this example, here's that approach.

      1) Create a new array of the same size as the original array.
      2) Match up the current element with other element indexes until you find a mismatch.
      3) Add an element to a 'TempArray' and update an element that was found to be a mismatch.
      4) Go over the array starting from the index location of '0'."

      Written by Tom Dushaj on August 31st, 2021