This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"sort" | |
"strconv" | |
"strings" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
/* | |
Race Condition - The condition occurs when two or more operations try to execute | |
simultaneously resulting in undeterministic output(s). | |
*/ | |
func inc(x *int) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
func doSomething(wg *sync.WaitGroup, tsk int, args ...string) { | |
defer wg.Done() | |
fmt.Printf("\n---- From Thread %d ----- \n", tsk) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"sort" | |
"strconv" | |
) | |
func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A simple graph based app - Like in Linkedin and Facebook | |
const social_network = [{ | |
id: 1, | |
name: "manju", | |
friends: [2, 4] | |
}, { | |
id: 2, | |
name: 'siddu', | |
friends: [1, 5], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
constructor(val, next = null) { | |
this.val = val; | |
this.next = next; | |
} | |
}; | |
class List { | |
constructor(list) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Subset Pairs - fp style | |
* P = numbers, S = sumRequired | |
* subSetPairs - returns all possible unique pairs | |
*/ | |
const subSetPairs = (numbers, sumRequired) => { | |
return numbers.map((num, idx) => [ | |
numbers[idx], | |
...numbers.slice(0, idx), | |
...numbers.slice(idx + 1, numbers.length) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gzip on; | |
gzip_comp_level 6; | |
gzip_buffers 16 8k; | |
gzip_types application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component application/x-javascript text/xml application/octet-stream; | |
gzip_proxied expired no-cache no-store private auth; | |
client_max_body_size 0; | |
underscores_in_headers on; | |
limit_req_zone $binary_remote_addr zone=uploadlimit:10m rate=3r/s; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const G = [ | |
[Infinity, 3,Infinity], | |
[3, Infinity, 6], | |
[Infinity, 6, Infinity], | |
]; | |
const dijkstras = (G, start) => { | |
let N = G.length; | |
let visited = new Array(N).fill(false, 0, N); | |
let route = new Array(N).fill(start, 0, N); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const quicksort = (arr) => { | |
if(arr.length < 2) return arr; | |
const pivotIndex = Math.floor(arr.length / 2); | |
const pivot = arr[pivotIndex]; | |
let less = []; | |
let more = []; | |
for(let i=0; i < arr.length; i++) { | |
if(i!=pivotIndex) arr[i] >= pivot ? more.push(arr[i]) : less.push(arr[i]); | |
} | |
return [ |