-
Continue reading →: 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…
-
Continue reading →: 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…
-
Continue reading →: 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…
-
Continue reading →: 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,…
-
Continue reading →: Basic calculator II
In this post we will discuss https://leetcode.com/problems/basic-calculator-ii/ There are 3 apporaches : 2 stack1 stack0 stack We will go over each 1 by 1. Evaluating Arithmetic Expressions with +, -, *, / Using Two Stacks We want to solve an arithmetic expression that includes operators like +, -, *, and…
-
Continue reading →: Cycle detection Directed graph BFS
In DFS, cycle detection works because you can track the current recursion path — the exact nodes you’re actively exploring.When you revisit a node in the same path, that’s a back edge, indicating a cycle.But BFS is fundamentally different:BFS explores nodes level by level, not along a single path.It doesn’t…
-
Continue reading →: Detecting a Cycle in a Directed Graph — A Thoughtful Progression
We are given a directed graph. The task is to detect whether the graph contains a cycle. 🧠 Thought ProcessTo detect a cycle, we start from a node and attempt to traverse through the graph.If during this traversal, we encounter the same node again in the current path, we have…
-
Continue reading →: Counting sub arrays
Counting Subarrays: 🔢 Step 1: Understanding Total SubarraysGiven an array of size n, how many contiguous subarrays can we form? Example: For [1, 2, 3, 4], the subarrays are: 11 21 2 31 2 3 422 32 3 433 44 Total = 10 subarrays. 📘 General RuleIf array size is…
-
Continue reading →: Design Pattern CheatSheet
https://docs.google.com/spreadsheets/d/e/2PACX-1vQyOMRgVppwRcD8oFTaqqqXh0etz4NA5wRYrqhncT1Ue_DKliRfPlMfQMHq_r_DmfaZuarAb49fAkjx/pubhtml?widget=true&headers=false Referred from : http://www.lug.or.kr/files/cheat_sheet/design_pattern_cheatsheet_v1.pdf Follow more posts @ https://jdecodes.wordpress.com My design pattern articles :
-
Continue reading →: DECORATER Design Pattern
The Decorator pattern allows you to dynamically add new behaviors to objects at runtime without altering their original class. It achieves this by wrapping existing objects in a new “decorator” object. Decorators share the same interface as the objects they wrap, enabling seamless integration and composition of functionalities. Too bookish…