Hey, I’m Justin ๐Ÿ‘‹

Welcome to my blog โ€” Its some random thoughts from a foolish developer!

Remove more than two duplicates in-place

Problem Given an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative order of the elements should be kept the same. Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. More formally, if there are k elements after removing the duplicates, then the first k elements of nums should hold the final result....

June 9, 2025

Inplace element removal an easy one

Problem Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the number of elements in nums which are not equal to val. Consider the number of elements in nums which are not equal to val be k, to get accepted, you need to do the following things: Change the array nums such that the first k elements of nums contain the elements which are not equal to val....

June 7, 2025

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

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