Day 1 of  10: IngressiveForGood 10 days of Code

Day 1 of 10: IngressiveForGood 10 days of Code

I've been learning python for three months now on DataCamp through the I4G scholarship.

At first, I always felt that I hadn't learned enough to participate in challenges. When the I4G 10 days of code application was opened, I decided to give it a try! What's the worst that could happen, right? Worst case, I fail and learn from my mistakes, and hey, thats not entirely a bad scenario.

So here I am, on the first day of 10 days of Code.

Instructions

Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. Without adding extra spaces

My Solution

My first approach to this was to use the set() method to obtain unique values and then sort using sorted(). However, this introduced extra space in memory for an array.

So, I modified my code to iterate through the array given and store non-repeated values in a new list and then replaced the given array with the new list.

Here's my submission below:

day 1 submission.jpg

And that's it for my first attempt at a challenge. I hope to continue to the end and maybe win a prize.

See you tomorrow for Day 2.