top of page


Tutorials, Errors and Exceptions
Its a journey to understand things better. It will have tutorials, any error/exceptions encountered, its resolutions and lots of learning.

Search


Spring Data JPA with MongoDB
In this post we will create a simple Spring JPA project which will connect to MongoDB and create a document, where we will save records...
Ankit Agrahari
Dec 3, 20213 min read
Β
Β
Β


Testing in Microservices
In this post we will go through the integration testing of the controller of any Spring Boot project. We will be using an existing Spring...
Ankit Agrahari
Dec 1, 20213 min read
Β
Β
Β


#LC1481 - Find Least Number of Unique Integers After K Removals
In this post, we will look into one of the Leetcode problem #1481, where we have to find the least number of unique integers after...
Ankit Agrahari
Nov 30, 20212 min read
Β
Β
Β


#LC983 - Find The Minimum Cost For Tickets (DP)
In this post we will go through the Leetcode #983 to find the minimum cost for Tickets, which could be one of the starting practice...
Ankit Agrahari
Nov 29, 20212 min read
Β
Β
Β


Read/Write Excel Using Apache POI & Java
This post will explore Apache POI library which is used to read any excel document and can also edit the excel sheets. Apache POI (Poor...
Ankit Agrahari
Nov 28, 20213 min read
Β
Β
Β


#LC226 - Inversion Of Binary Tree Using Recursion
Following the last post on the binary tree traversals, in this post we will try to invert a given binary tree. Binary tree is a data...
Ankit Agrahari
Nov 27, 20212 min read
Β
Β
Β


#LC105 - Binary Tree from In-Order and Pre-Order Traversal
In this post we will create a binary tree from the given in-order and pre-order traversal. You can find the details on the question here...
Ankit Agrahari
Nov 26, 20214 min read
Β
Β
Β
Contact
bottom of page



![If this shifted how you think about AI β
you're ready to Harness it. π₯
π¬ Comment "HARNESS" below
β I'll DM you the open-source agent template
π Save this carousel β refer back when you build
π€ Share with one engineer who's still copy-pasting
Follow @backendbrilliance for more content on
AI agents, Spring Boot architecture & backend systems
that actually scale.
#AIHarnessing #BackendBrilliance #JavaDeveloper
#SpringBoot #SpringAI
[AIAgents SystemDesign BackendEngineering SoftwareDevelopment LLMOps]](https://scontent-den2-1.cdninstagram.com/v/t51.71878-15/729219604_894359219640315_5276418046541229917_n.jpg?stp=dst-jpg_e35_tt6&_nc_cat=102&ig_cache_key=MzkyNjU3ODk3MzMyNzMxMTg2Mw%3D%3D.3-ccb7-5&ccb=7-5&_nc_sid=a54f6b&efg=eyJlZmdfdGFnIjoiYmVzdF9pbWFnZV91cmxnZW4uQ0xJUFMuQzIifQ%3D%3D&_nc_ohc=VsI4oeqheXIQ7kNvwFW2IU2&_nc_oc=Adq2SyKjf9Dx5eowG1P4OUDveFHqY-e3nNTl0fmjYqyrVaWUI3S9C0p5TshZKH3JZAo&_nc_zt=23&_nc_ht=scontent-den2-1.cdninstagram.com&edm=ANo9K5cEAAAA&_nc_gid=RY7Re5xSDKFBaYDVXExXrQ&_nc_tpa=Q5bMBQIc0Q8emU-JRDKhmzjpNfNq_Pds7GqzvbipYr3knc5K4RPB5ng_Ai1izE01mzj95TH7Cesn2Ftt&oh=00_AQIeV-dK80XX_3ZdxuEb4d0pa65FGdds_8_ZX-CKKGh_Ug&oe=6AB2D92F)























![You think HashMap is always O(1).
It isn't. Here's what actually happens. π§΅
HashMap stores pairs using `index = hash(key) % capacity` β direct slot access, no scanning. Pure O(1). Until two keys land on the same slot. That's a collision β not a bug, a math inevitability.
Two ways to fix it π
π Chaining β each bucket holds a linked list. Collisions append to the list. Simple, handles high load, easy deletion. Downside: pointer overhead, poor cache performance, chains degrade to O(n) at high load. Java's fix? At 8 nodes, the list auto-converts to a Red-Black Tree β O(log n) worst case.
π¦ Open Addressing β no linked lists. Collision at slot X? Probe X+1, X+2 until empty. Cache-friendly, zero memory overhead. Downside: deletion needs tombstone markers, and keys cluster together making future collisions worse. Used by C++, Go, Redis.
βοΈ Load Factor = entries Γ· capacity
π’ Below 0.5 β rare collisions, wasted memory
π 0.75 β Java's sweet spot, triggers resize + rehash
π΄ Above 0.9 β collision cascade, O(n) territory
Double hashing kills clustering by varying the probe step per key:
`probe(i) = (h1 + i Γ h2) % m`
Elements scatter evenly. No bunching. O(1) preserved.
The truth: HashMap is O(1) until a bad hash function, wrong load factor, or wrong strategy turns it into O(n).
Three things protect you:
β Well-distributed hash function
β Load factor under 0.75
β Right collision strategy for your use case
π¬ Java interview question: what happens when a chain hits 8 nodes?
Drop your answer below π
π Save this before your next interview.
#java #hashmap #datastructures #dsa #algorithms
[codinginterview programming 100daysofcode]](https://scontent-den2-1.cdninstagram.com/v/t51.71878-15/641188820_1859196944673752_5535080284006983284_n.jpg?stp=dst-jpg_e35_tt6&_nc_cat=102&ig_cache_key=Mzg0NDY4MjE0NzAzMTAyMzAyNA%3D%3D.3-ccb7-5&ccb=7-5&_nc_sid=a54f6b&efg=eyJlZmdfdGFnIjoiYmVzdF9pbWFnZV91cmxnZW4uQ0xJUFMuQzIifQ%3D%3D&_nc_ohc=vOsupNueuZQQ7kNvwG6RzzV&_nc_oc=AdpeFrQ8sAtf3Czf0B-yIH2OjClO6DjXMLl34kWXa3e4NNssPbIO8OsByZb_1ZC-YEY&_nc_zt=23&_nc_ht=scontent-den2-1.cdninstagram.com&edm=ANo9K5cEAAAA&_nc_gid=RY7Re5xSDKFBaYDVXExXrQ&_nc_tpa=Q5bMBQIrNtsQXln7RD9BVVhnT23dU5MYAD4mDpTy9OvA98PraS6q2nHpIobwMBvjqFhefFuea8oggxCz&oh=00_AQJeVij66_dar9kBUIGrkfyXndGj9Ib4ToMB4aQX1_Gchw&oe=6AB2CD7E)


