A Fresh Start: My First Day on the DSA Learning Journey
Today marked the initiation of my Data Structures and Algorithms (DSA) learning journey, and it feels like a fresh beginning. As mentioned in my previous blog, I've attempted to delve into DSA a couple of times before without much success. However, today I approached it with renewed enthusiasm.
Keeping the first day light, I tackled two DSA questions revolving around the concepts of arrays and hashtables. I'm currently following neetcode's DSA playlist as my guide for learning DSA.
The initial question focused on checking for duplicates in an array. The optimal approach to solve this problem involved utilizing a hashset, a datatype similar to a hashtable or hashmap. Although a hashset allows storing null values, it doesn't guarantee a constant order of entries. The code was straightforward; each unique value was stored in the hashset, and if any entry matched a value already stored, it would print true.
The second question involved determining if two words were valid anagrams (meaning one word could be formed using all the letters of another). The initial step was to check if the lengths of both strings were the same; if not, the code would print false. We employed two hashtables to store characters and their respective occurrences. If both tables were identical, the words were considered anagrams, and the code would print true.
That concludes today's progress in my DSA learning journey. I'll keep you all updated on my future endeavors. Wish me luck!