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 / DiamondProblemRevisited.java
Created August 22, 2019 08:20
How the diamond problem is handled when Java 8 introduced the default method implementation in interface
interface Poet {
default void write() {
System.out.println("Poet writes poems");
}
}
interface Writer {
default void write() {
System.out.println("Writer writes stories");
}
@kuntalchandra
kuntalchandra / pull_request_template.md
Last active August 22, 2019 10:46
Pull request template

PR Checklist

A self-explanatory title describing what the pull request does. If possible, provide the link of the epic in the description, will be helpful to the reviewer e.g.

  • 1. Does the design meet the expectation?
  • 2. Do we have the required test coverage?
  • 3. Have domain-oriented test cases been reviewed by an analyst?
  • 4. Does the PR address the targetted issue and not a mix of multiple issues etc.?

Motivation

  • Explain the context and purpose e.g. Does the design follow OCP so that in near future it can be extended easily?
@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 / selecttionsort.c
Last active April 28, 2020 07:33
How Selection Sort works
/**
* Implementation of Selection sort
* In place algo
* Average Performance О(n^2) comparisons, О(n) swaps
* Space complexity: O(1)
*/
#include <stdio.h>
void display(int arr[], int n);
void selection_sort(int input[], int n);
@kuntalchandra
kuntalchandra / insertionsort.c
Last active April 28, 2020 07:33
How Insertion Sort works
/**
* Implementation of Insertion sort
* In place algo
* Average Performance О(n^2) comparisons and swaps
* Space complexity: O(1)
*/
#include <stdio.h>
void display(int arr[], int n);
void insertion_sort(int input[], int n);
@kuntalchandra
kuntalchandra / recursion.c
Last active December 3, 2019 12:50
How does recursion work. Guess the output :)
#include <stdio.h>
void print_recursive(int n);
int main() {
print_recursive(7);
}
void print_recursive(int n) {
if (n <= 0) {
@kuntalchandra
kuntalchandra / mergesort.c
Last active June 13, 2020 06:05
Implementation of Merge sort
/**
* Implementation of Merge sort
* Not in place algo
* Average Performance O(n log n)
* Space complexity: О(n) total with O(n) auxiliary, O(1) auxiliary with linked lists
*/
#include <stdio.h>
void display();
void sort(int low, int high);
@kuntalchandra
kuntalchandra / toh.c
Last active January 7, 2020 17:11
Solution to the tower of hanoi problem
/**
* Solution to the tower of hanoi problem
* Moves: O(2^n)-1
* Time complexity: O(2^n)
*/
#include <math.h>
#include <stdio.h>
void toh(int n, char source, char dest, char aux);
@kuntalchandra
kuntalchandra / linked_list.c
Last active April 28, 2020 07:30
Linked List operations
/**
* Linked List implementation
* Operations: Create list, insert value to last, insert value to first, insert at specific position, search a value, delete a value and traverse list
* Average Time Complexity
* Insert/delete at beginning Θ(1)
* Insert/delete at end Θ(1)
* Insert/delete in middle search time + Θ(1)
* Space complexity: O(n)
*/
@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>