Skip to content

Instantly share code, notes, and snippets.

View anish000kumar's full-sized avatar
🎯
Focusing

Anish Kumar anish000kumar

🎯
Focusing
  • Gurgaon, India
View GitHub Profile
@anish000kumar
anish000kumar / reverseLinkedList.js
Last active November 9, 2018 17:44
reverse a linked list
function reverseLinkedList(head){
let prev = null;
let next = null;
while(head){
next = head.next;
head.next = prev;
prev = head;
@anish000kumar
anish000kumar / numsort.js
Last active November 8, 2018 13:52
Sort array of numbers
numArray.sort((a, d) => a - d); // For ascending sort
numArray.sort((a, d) => d - a); // For descending sort
@anish000kumar
anish000kumar / hackerearth_js_boilerplate.js
Last active October 23, 2018 20:04
hackerearch js boilerplate
process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";
process.stdin.on("data", function (input) {
stdin_input += input; // Reading input from STDIN
});
process.stdin.on("end", function () {
var Queue = (()=>{
const map = new WeakMap();
let _items = []
class Queue{
constructor(...items){
//initialize the items in queue
map.set(this, []);
_items = map.get(this);
// enqueuing the items passed to the constructor
this.enqueue(...items)
@anish000kumar
anish000kumar / Stack.js
Last active July 27, 2018 15:21
Stack implementation in javascript (es6)
let Stack = (()=>{
let map = new WeakMap();
let _items = [];
class Stack {
constructor(...items){
// let's store our items array inside the weakmap
map.set(this, []);
// let's get the items array from map, and store it in _items for easy access elsewhere