-
Linux Device Drivers 101 : 001# Module Loading
Intention Recently, i thought to learn about linux device drivers and started reading LDD, so I will be summarizing my learnings here. So, Simple step towards linux device driver is writing a simple module. I am using ubuntu machine and will be doing experiments on that. 1. Writing a Simple Loadable Module Basically, a module:…
-
Sliding Window Median
Today, I will talk about https://leetcode.com/problems/sliding-window-median/description/ When I looked at this problem, I thought it should be just an extension to “Median in Data Stream”, But I tried hard to use 2 heap solution and could not find a way to do. So, I started back with a brute force solution and few other ideas.…
-
Custom Comparators
Generally in sorting, we may have to deal with custom sort functions, so what is the intutution behind those and how a custom compartor can actually work, we will see the stl solution and then hook the compartor in merge sort (our own version of merge sort, working merge sort, which doesn’t give a TLE…
-
Graphs
These are few questions 1 should do while doing graphs BFS https://www.geeksforgeeks.org/problems/bfs-traversal-of-graph/1 DFS https://www.geeksforgeeks.org/problems/depth-first-traversal-for-a-graph/1 https://leetcode.com/problems/number-of-islands/description/ https://leetcode.com/problems/number-of-provinces/description/ https://www.geeksforgeeks.org/problems/detect-cycle-in-an-undirected-graph/1 In undirected graphs, need to track of parent and skip when A-B, so skip pushing parent in queue https://leetcode.com/problems/01-matrix/description/ distance from all zeros, multi source bfs, push all zeros to queue https://leetcode.com/problems/course-schedule/description/ Topological sort https://leetcode.com/problems/course-schedule-ii/description/ Cycle detection via…
-
Binary Search
Binary search is a simple algo, check mid value, compare, ignore invalid half, move to the valid half until completed / element is found.But the code has many variable, low, high, midShould the loop be while (low < high) or while (low <= high)?or high = mid -1 or high = mid ;What exactly these…
-
Find Median from Data Stream
In this post, we will talk about leetcode 295: https://leetcode.com/problems/find-median-from-data-stream/description/ Problem looks simple, we need to find a Median of data stream, we can sort at each getMedian call. In short we have a such algo: Maintain a dynamic array or list.On every new number:Insert it into the list.To get the median:Sort the list.Return the…
Subscribe
Enter your email below to receive updates.