The nicest way to merge two sorted arrays

You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 and nums2 into a single array sorted in non-decreasing order. The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate this, nums1 has a length of m + n, where the first m elements denote the elements that should be merged, and the last n elements are set to 0 and should be ignored....

June 6, 2025

gRPC - The Witchcraft of Remote Procedure Calls

WTF is gRPC? Why GRPC ? Some technologies are like witchcraft. You hear about them, you see them in action, but you don’t really understand how they work. gRPC is one of those technologies for me. It’s a remote procedure call (RPC) framework that allows you to define services and methods in a language-agnostic way, and then generate client and server code in multiple languages. So what it means is there is a ....

June 3, 2025

Replication - Leaders and Followers

Replication - Leaders and Followers Replication, or read replica is a process of copy pasting data from a primary database to another database. This is done to improve performance, availability, and reliability of the database. Replication can be done in two ways: synchronous and asynchronous. In synchronous replication, the primary database waits for the replica to acknowledge that it has received the data before it can proceed. This ensures that the data is always consistent between the primary and replica databases, but it can also slow down the performance of the primary database....

May 20, 2025

IP V4 Subnetting tricks and basics

IP V4 Subnetting tricks and basics Introduction As usual lets try to be little intellectual. By saying a qoute i got it from chatgpt. “Good subnetting is like good carpentry: measure twice, cut once.” What ever it means it doesnt matter. But the point is to understand the concept of subnetting and how it works. This is somehow one of the most mind f**k*ng topic which i encoutered during my job....

May 13, 2025

Utils

First tool: Subnet Calculator If you want to calculate the subnet, you can use the following tool. It will help you to calculate the subnet, broadcast address, and usable IP addresses. Loading message...

May 13, 2025

Enterprise Over Engineering

The Hidden Pitfalls of Overusing Design Patterns This is my story of using the Chain of Responsibility pattern after reading about it in a book while preparing for an interview. Yes — I actually used it in a real job. And well, it didn’t turn out the way I had imagined. Before we dive in, here’s a quote from one of my favorite authors, Khaled Hosseini (The Kite Runner): “There is only one sin, only one....

April 27, 2025

മധുരം മലയാളം. ഒരു മലയാളം പ്രോബ്ലം സോൾവിങ്

എനിക്ക് പലപ്പോഴും തോന്നിയിട്ടുണ്ട് നമ്മുടെ ഏതു ഭാഷയിലാണ് നമ്മളുടെ ബ്രെയിൻ പ്രവർത്തിക്കുന്നത് എന്ന്. ഇന്റർനെറ്റിൽ പരതുമ്പോൾ നമ്മുക്ക് മനസിലാകും ബ്രെയിൻ symbols ഉം മോഡലുകളും ആണ് ഉപയോഗിക്കുന്നത് എന്ന്. പക്ഷെ ഒരു പ്രോബ്ലം സോൾവ് ചെയ്യുമ്പോൾ നമ്മുടെ ബ്രെയിൻ കൂടുതൽ സമയവും ചിലവഴിക്കുന്നത് ഐഡിയകളെ പരിഭാഷ ചെയ്യാൻ ആയിരിക്കും. പ്രത്യേകിച്ച് മലയാളായി ആയ എനിക്ക് ഇതൊരു പ്രശ്നമായി തോന്നിയിട്ടുണ്. ചില പ്രോബ്ലെംസ് സോൾവ് ചെയ്യുമ്പോൾ എനിക്ക് കൂടുതൽ വഴങ്ങുന്ന ഭാഷ അത് മലയാളം ആണ്. ഉദാഹരണത്തിന് ഈ പ്രോബ്ലം നോക്കൂ. Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining....

April 6, 2025

Managing Concurrent Updates with Distributed Locks

Managing Concurrent Updates with Distributed Locks Managing Concurrent Updates with Distributed Locks In distributed systems, managing concurrent access to shared resources is crucial to ensure data consistency and prevent corruption. Let’s explore how to handle this using a Java example, starting with a basic implementation and improving it step-by-step. Basic Implementation Without Proper Lock Handling Here’s a simple version of a method that tries to acquire a distributed lock, perform an update, and release the lock:...

May 30, 2024

Revisiting Dynamic Programming

The main problem with me w.r.t DP problem is forgetting it if i don't practice. So I decided to revisit all the DP problems i solved once again just to refresh my memory. So first Lets start with a simple one. Here we go!!! Climbing stairs from Leetcode. Explanation : You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps....

March 19, 2024

Java Design Patterns - JDP Series #1

Design patterns are general reusable solutions to common problems that occur in software design. They are not code, but rather guidelines on how to solve a particular problem in a particular context. They are not a finished design that can be transformed directly into code. They are a description or template for how to solve a problem that can be used in many different situations. Types of design patterns in Java -------------------------------- There are three types of design patterns in Java: * Creational...

March 7, 2024