05-1 : Top K Frequent ElementsOverview I walk you through how to solve Leetcode problem 347. Top K Frequent Elements. Approach 1: Count HashMap def topKFrequent(nums, k): count = {} res = [] for n in nums: count[n] = count.get(n, 0) + 1 for _ in range(k): ...Apr 30, 2023 · 2 min readrohanmorar.hashnode.dev
04-1 : Group AnagramsOverview I walk you through how to solve Leetcode problem 49. Group Anagrams. There are a couple of approaches to solving this problem. I will highlight both approaches as well as the time and space complexity trade-offs between each approach. Approa...Apr 28, 2023 · 2 min readrohanmorar.hashnode.dev
Binary Search Tree (BST) OverviewBackground Linked List vs. Array - search() Linked lists have a slight downside when it comes to finding an item. If the item we're trying to find is located towards the end, then we'd have to traverse nearly all nodes until it's found. The result is...Apr 28, 2023 · 4 min readrohanmorar.hashnode.dev
03-2 : Count characters in your stringThis is a CodeWars problem that requires returning a HashMap of the count of characters within a string. Approach 1: HashMap def count(s): letterCount = {} for c in s: letterCount[c] = 1 + letterCount.get(c, 0) return letterCount ...Apr 27, 2023 · 1 min readrohanmorar.hashnode.dev
03-1 : Two SumI walk you through how to solve Leetcode problem 1. Two Sum. I highlight a couple of approaches to solving it. As usual, there are various trade-offs between time and space complexity respective to each approach. Approach 1: Brute Force def twoSum(nu...Apr 27, 2023 · 1 min readrohanmorar.hashnode.dev