The Beauty of Previous Knowledge - More Leetcode Problems #Day2
Removing an element in an array (I4G 10 Days Of Code Challenge)
Table of contents
One of the most beautiful things in the world is when a current problem being faced has certain similarities with a problem that has already been faced. This was the case for this current problem as it shared a lot of similarity with Day 1's Challenge.
The Challenge
Approach to Solution
As you can see, this challenge shares similar attributes to the first challenge, so basically using a similar idea of Day 1's challenge, I arranged my code with this process
- Loop through each of the array's elements
- Check if each element corresponds with the value given
- If value corresponds, delete the value in array
- Increment the counter of the array A pseudocode would look like this:
while count is less than array length
if value is in array
delete array[index]
increment count
k = length of array
Finally Did It