ylliX - Online Advertising Network
100 day challenge of data structure and algorithm in Swift

100 day challenge of data structure and algorithm in Swift


Since January, I’ve been slowing down blogging for couple reasons: I started doubting about myself and the quality of my content but I also wanted to focus more on some fundamentals I felt I was missing. So I committed to a “100 day challenge” coding challenge, focused on data structure and algorithm in Swift.

Before drafting a program to organize my challenge, I had to identify what I didn’t know and what I wanted to learn. I really wanted to focus on data structure and algorithm, so I tried myself on algorithm exercises. After failing a lot of them, I managed to make a list of fundamentals that I was missing: a lot were things I used to know and forgot over time, other just missing completely.

I knew well some data structure that are common to iOS development like Array, Hashmap or Set. However, some others felt almost new like Trie, Heap or Graph. However, the more I learnt about it, the more I saw parallels and applications of it in iOS development. For instance, UIView in iOS is very similar to a Tree, and UINavigationController pushing system similar to a LinkedList implementation.

After a week or two focused on brushing-up on data structure on daily basis, I exercised re-implementing each of them in Swift as well as Objective-C. The logic of a data structure is the same across platform, so being able to code one regardless of the language reinforce my understanding of it.

I also took time to share Swift implementations for some of them, like Queue, Stack or Tree.

Once feeling more confident about data structure, I moved on to the algorithm side, digging into Binary Search, Sorting, Recursion, Backtracking and so on.


It required a bit more organization to find qualified and structured content. This came from different resources: videos from Youtube, tutorials from computer science blog or even plain old white papers.

Same as data structure, it’s important to understand the concept before diving into the code. Once I understood the idea, I trained re-implementing it in Swift and Objective-C to make sure I got it right.

At that point, I also started testing myself against algorithm problems. I knew about LeetCode, so I trained with it during all those months.

I won’t lie, if you are not use to these kind of problems, you feel hitting a wall. This is where mental is key.

At first, it’s hard to realize any progress, problems look really difficult and solutions feel not intuitive at all. It just require more patience and working harder to go through it, eventually each problem looks alike and I started seeing a pattern between them.

From that point, it gets easier to find the best solution if you have an intuition of what type of problem it is. Unfortunately, there is no real secret to get there: the only way is to work hard and go through.

Half way through it, about 6 weeks from the start, I thought it was time to challenge what I learnt so far. So I reset my LeetCode session, clearing all solutions submitted and start from scratch again. The idea was to start again and see what I learnt and if I was better at it.

Turns out, I did. The easy problems felt easier that I recalled, the medium felt more balanced and so on. Obviously, it wasn’t all perfect, but I could identify again my flaws and see what I could improve. So I adapted my content and went back to built my fundamentals on those subjects again.

It does sound a repetitive process, and maybe you feel you know well enough most algorithms, but I was actually surprised how much content I could dig out on specific subject. For instance, I learnt about sort algorithm but I got even more interested why sorting can’t go faster than O(n log n).

So what does one of those 100 days looks like?

What matters is to commit to the challenge, next to your usual routine. I personally tried to squeeze an hour in early morning, one or two video contents at lunch time, and about 2 to 3 hours in the evening. On the week-end, 3 to 4 hours on the morning and whatever I can do later if my brain isn’t fried yet. It might sounds maybe too much, or maybe too little, depends where you stand.

To me, consolidating that knowledge was very important to many reasons:

  • First is that I sucked at it, now I suck a bit less.
  • It also helps a lot on daily basis, or at least, more that we can think. Talking about problem or performance, you can recognize the same challenging pattern you met before and find small improvements.
  • It helps me build confident about my writings, having a deeper understanding of structures and systems.
  • Finally, it can help your career, keeping skills sharp as an candidate for a next job but also as an interviewer if you need to assess software engineer skill set.

After hundreds of problem resolved, and even though the learning curve felt steep, this subject grew in me, I enjoy more those algorithm questions now than when I started. Now, it’s all about keep this training alive, resolving couple questions every week and making more research whenever possible. My only advise is to not give up, it’s worth it as long as you have a clear goal.


To go further

Photo credits Ali Yahya



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *