Skip to content

Instantly share code, notes, and snippets.

View kuntalchandra's full-sized avatar
🎯
Focusing

Kuntal Chandra kuntalchandra

🎯
Focusing
View GitHub Profile
@kuntalchandra
kuntalchandra / in_memory_cache.py
Created April 2, 2026 12:04
Mock LLD of in-memory cache
from abc import ABCMeta, abstractmethod
from collections import defaultdict
from datetime import datetime, timedelta
import hashlib
import threading
# Design philosophy
# Flow:
# Client → CacheClient → ShardRouter → CacheNode → Storage
#
@kuntalchandra
kuntalchandra / ecommerce_management.py
Created April 1, 2026 11:40
LLD of generic e-commerce
"""
Core Design Principles Used- Strategy Pattern
Payment methods
Notification channels
Runtime polymorphism
Loose coupling
Extensible services
User → Cart → Order → Payment → Notification
"""
"""
Use case components
1. Actors
- Member (User)
- Librarian (Admin)
2. Core Requirements (mapped to use-cases)
- Search books
- Issue / Return book
- Reserve book
- Add / Remove / Update book
@kuntalchandra
kuntalchandra / agent.py
Created January 29, 2026 05:00
Regression analyzer sample code
"""Main agent orchestrator for regression analysis."""
import logging
from typing import Optional
from regression_analyser.github_client import GitHubClient
from regression_analyser.code_analyzer import CodeAnalyzer
from regression_analyser.endpoint_mapper import EndpointMapper
from regression_analyser.ai_agent import RegressionAnalyzerAgent
from regression_analyser.comment_formatter import CommentFormatter
@kuntalchandra
kuntalchandra / hotel_management.py
Last active August 9, 2024 03:36
Mock LLD of Hotel Management
from abc import ABCMeta, abstractmethod
from enum import Enum
from typing import List, Optional
# Enum Definitions
RoomStyle = Enum("RoomStyle", "STANDARD DELUX SUITE")
RoomStatus = Enum("RoomStatus", "AVAILABLE RESERVED NOT_AVAILABLE OCCUPIED SERVICE_IN_PROGRESS")
BookingStatus = Enum("BookingStatus", "PENDING CONFIRMED CANCELED")
@kuntalchandra
kuntalchandra / largest_integer.py
Created April 1, 2021 10:03
Given an array of integers A, return the largest integer that only occurs once.
"""
Given an array of integers A, return the largest integer that only occurs once.
If no integer occurs once, return -1.
Example 1:
Input: [5,7,3,9,4,9,8,3,1]
Output: 8
Explanation:
@kuntalchandra
kuntalchandra / palinedrome_linked-list.py
Created April 1, 2021 10:02
Given the head of a singly linked list, return true if it is a palindrome
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def isPalindrome(self, head: ListNode) -> bool:
numbers = []
sentinel = head
while sentinel:
@kuntalchandra
kuntalchandra / valid_mountain_array.py
Created December 10, 2020 13:25
Valid Mountain Array
"""
Given an array of integers arr, return true if and only if it is a valid mountain array.
Recall that arr is a mountain array if and only if:
arr.length >= 3
There exists some i with 0 < i < arr.length - 1 such that:
arr[0] < arr[1] < ... < arr[i - 1] < A[i]
arr[i] > arr[i + 1] > ... > arr[arr.length - 1]
@kuntalchandra
kuntalchandra / bst_iterator.py
Created December 10, 2020 05:07
Binary Search Tree Iterator
"""
Implement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST):
BSTIterator(TreeNode root) Initializes an object of the BSTIterator class. The root of the BST is given as part of
the constructor. The pointer should be initialized to a non-existent number smaller than any element in the BST.
boolean hasNext() Returns true if there exists a number in the traversal to the right of the pointer, otherwise
returns false.
int next() Moves the pointer to the right, then returns the number at the pointer.
Notice that by initializing the pointer to a non-existent smallest number, the first call to next() will return the
smallest element in the BST.
@kuntalchandra
kuntalchandra / place_flowers.py
Created December 5, 2020 10:15
Can Place Flowers
"""
You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted
in adjacent plots.
Given an integer array flowerbed containing 0's and 1's, where 0 means empty and 1 means not empty, and an integer n,
return if n new flowers can be planted in the flowerbed without violating the no-adjacent-flowers rule.
Example 1:
Input: flowerbed = [1,0,0,0,1], n = 1
Output: true