Skip to content

Instantly share code, notes, and snippets.

View focks's full-sized avatar
🎯
Focusing

Chandan Kumar Singha focks

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am focks on github.
  • I am ichandan (https://keybase.io/ichandan) on keybase.
  • I have a public key ASBunnD5ePkDSBC5qaJ9S73-7ZPm97H86_5j-2XNnwG8Wgo
@focks
focks / go-cheatsheet.md
Created April 5, 2018 05:16
go cheat-sheet

Go Cheatsheet

Read String from standard input

import (
  "bufio"
  "os"
)

reader := bufio.NewReader(os.Stdin)
@focks
focks / matrix_multiplication.c
Created February 4, 2018 13:43
multiprocess matrix multiplication -- memory sharing
#include <stdlib.h>
#include <stdio.h>
#include <sys/ipc.h>
#include <sys/shm.h>
static int A[1001][1001], B[1001][1001];
int shmbuf;
key_t key;
int (*ans)[1001];
@focks
focks / credentials.py
Last active October 13, 2017 13:58
create jenkins credentials
#!/usr/bin/python
import requests
import uuid
url = "http://jenkins:8080/credentials/store/system/domain/_/createCredentials"
def create_credential(credentials):
""":param: credentials: format should be
{
"scope": "GLOBAL",
"username": "adaikal",
### Graph Algoritms (Implementations)
- Articulation Points
- Union Find (Disjoint Set DS) cycle detection
- kruskal minimum spanning tree
@focks
focks / InsertionSort.cc
Last active July 27, 2016 10:12
Sorting
void insertionSort(vector<int> &A){
int n = A.size();
int j, key;
for(int i=1;i<n;i++){
j = i-1;
key = A[i];
while(j>=0 and A[j] > key){
A[j+1] = A[j];
j--;
}
@focks
focks / LL_palindrome.cc
Created May 9, 2016 02:30
Given a singly linked list, determine if its a palindrome. Return 1 or 0 denoting if its a palindrome or not, respectively. - Expected solution is linear in time and constant in space.
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
int Solution::lPalin(ListNode* A) {
ListNode* ptr = A;
@focks
focks / LL_find_intersection.cc
Created May 8, 2016 17:23
Write a program to find the node at which the intersection of two singly linked lists begins.
ListNode* Solution::getIntersectionNode(ListNode* A, ListNode* B) {
/* find length of both the lists
* Advance the pointer of longest list to a node such that the distance becomes equal to that of the smaller list
* update the pointers of both the lists by one and check for match
*/
ListNode *list_one = A;
ListNode *list_two = B;
int len1=0;
int len2=0;
@focks
focks / Spiral-I.cc
Last active May 8, 2016 17:23
Given a matrix of m * n elements (m rows, n columns), return all elements of the matrix in spiral order.
vector<int> Solution::spiralOrder(const vector<vector<int> > &A) {
vector<int> ret;
int m = A.size();
int n = A[0].size();
int i=0, j=0;
while(i<=m and j<=n){
/* --- left ---- */
if(i<m){
for(int left=j;left<n;left++)