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 / 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 / above_average_subarrays.py
Created September 1, 2020 02:41
Above-Average Subarrays
"""
You are given an array A containing N integers. Your task is to find all subarrays whose average sum is greater than
the average sum of the remaining array elements. You must return the start and end index of each subarray in sorted
order.
A subarray that starts at position L1 and ends at position R1 comes before a subarray that starts at L2 and ends at R2
if L1 < L2, or if L1 = L2 and R1 ≤ R2.
Note that we'll define the average sum of an empty array to be 0, and we'll define the indices of the array (for the
purpose of output) to be 1 through N. A subarray that contains a single element will have L1 = R1.
Signature
@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 / print_random.py
Created August 22, 2019 13:06
Python: MagicMock, Patch and Side effect
import time
import uuid
class PrintRandom(object):
def execute(self) -> None:
while True:
self.print_number(uuid.uuid1().int)
time.sleep(1)
@kuntalchandra
kuntalchandra / ImageResizerMultiProcess.php
Created September 14, 2017 13:34
Forking multiple processes in PHP using pcntl_fork()
<?php
include("Lib.php");
class ImageResizerMultiProcess
{
private $sizes = [];
public function setSizes($sizes)
{
@kuntalchandra
kuntalchandra / cmd.sh
Last active August 1, 2022 05:53
Load testing example using Apache Bench (ab) to POST JSON to an API
# Shoot off 300 requests at the server, with a concurrency level of 10, to test the number of requests it can handle per second
# -p POST
# -H Authentication headers
# -T Content-Type
# -c Concurrent clients
# -n Number of requests to run
# -l Accept variable document length
# -k Connection keep-alive
# -v Verbosity level
@kuntalchandra
kuntalchandra / inorder_successor_bst_ii.py
Created September 15, 2020 10:56
Inorder Successor in BST II
"""
Given a node in a binary search tree, find the in-order successor of that node in the BST. If that node has no
in-order successor, return null.
The successor of a node is the node with the smallest key greater than node.val.
You will have direct access to the node but not to the root of the tree. Each node will have a reference to its
parent node. Below is the definition for Node:
class Node {
@kuntalchandra
kuntalchandra / pairs_with_specific_difference.py
Created April 29, 2020 13:51
Pairs with Specific Difference
"""
Given an array arr of distinct integers and a nonnegative integer k, write a function findPairsWithGivenDifference that
returns an array of all pairs [x,y] in arr, such that x - y = k. If no such pairs exist, return an empty array.
Note: the order of the pairs in the output array should maintain the order of the y element in the original array.
input: arr = [0, -1, -2, 2, 1], k = 1
output: [[1, 0], [0, -1], [-1, -2], [2, 1]]
input: arr = [1, 7, 5, 3, 32, 17, 12], k = 17
output: []
@kuntalchandra
kuntalchandra / stack.c
Last active March 2, 2022 23:50
Stack implementation using Linked List
/**
* Implementation of stack using Linked list
* Average Time Complexity
* Insert/delete Θ(1)
* Search Θ(n)
* Space complexity: O(n)
*/
#include <cstdlib>
#include <stdio.h>
#include <malloc.h>
@kuntalchandra
kuntalchandra / binary_tree_left_side_view.py
Created August 30, 2020 04:11
Number of Visible Nodes from Left
"""
There is a binary tree with N nodes. You are viewing the tree from its left side and can see only the leftmost nodes
at each level. Return the number of visible nodes.
Note: You can see only the leftmost nodes, but that doesn't mean they have to be left nodes. The leftmost node at a
level could be a right node.
Signature
int visibleNodes(Node root) {
Input