-
Priority Queue
In this article we will see different way to use max, min heap using priority_queue in cpp. By default, priority_queue creates a maxHeap. Max Heap Min Heap To implement a minHeap, we need to tell compiler to change default comparison order, which can be done via passing a different comparator. That was basic for ints,…
-
Process Memory Layout
Linux organizes the virtual memory space of a process into segments, each serving a specific purpose. This is crucial for memory safety, performance, and debugging. Here’s a standard layout from low to high memory: +————————-+ | Text Segment | ← Executable instructions +————————-+ | Initialized Data (.data)| ← Global/static vars with initial values +————————-+ |…
-
Process Vs Thread
Process: A process in Linux (and Android, which is Linux-based) is more than just running code — it’s a container of resources, including: Access to kernel-managed resources like memory maps, I/O handles, sockets, etc. Its own virtual address space One or more threads (each with its own stack) Open file descriptors Environment variables Signal handlers…
-
Random Pick with Weight
We will be discussing problem : https://leetcode.com/problems/random-pick-with-weight You are given a 0-indexed array of positive integers w where w[i] describes the weight of the ith index. You need to implement the function pickIndex(), which randomly picks an index in the range [0, w.length – 1] (inclusive) and returns it. The probability of picking an index…
-
Heap
📚 Table of Contents What Is a Heap Heapify Up vs Down Ways to Build a Heap Min Heap Code Max Heap Code Heap using STL A heap is a special tree-based data structure that satisfies the heap property. It is commonly used to implement priority queues, heapsort, and in many greedy algorithms like Dijkstra’s…
-
Basic Calculator
Here we will discuss : https://leetcode.com/problems/basic-calculator In Last article https://jdecodes.wordpress.com/2025/06/20/basic-calculator-ii/ we solved basic calculator where there was only, +, -, *, / Let’s make it bit more complicated. Now our problem has We’ll use the two-stack approach: one stack for values, another for operators. This gives us flexibility and clarity, just like how we evaluate…
Subscribe
Enter your email below to receive updates.