Skip to content

Instantly share code, notes, and snippets.

/* Container With Most Water
*
* @param {number[]} height
* @return {number}
*
* Input: height = [1,8,6,2,5,4,8,3,7]
* Output: 49
* Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49.
*/
@RakshithNM
RakshithNM / LRU.js
Last active April 13, 2022 04:37
Least Recently Used Cache
/* Implement Least Recently Used Cache
* Improvements to make
* 2. Invalidate only a specific node when there is no read/write on that node for a certain duration.
*/
/* Node that represents item of a doubly linked list */
class Node {
constructor(key, value, previous = null, next = null) {
this.key = key;
this.value = value;
@RakshithNM
RakshithNM / matrix.sh
Created February 18, 2022 20:29
matrix effect in the terminal on mac
#!/usr/bin/env bash
# Courtesy of @bvierra and company (long ago, pre-cPanel)
### Customization:
blue="\033[0;34m"
brightblue="\033[1;34m"
cyan="\033[0;36m"
brightcyan="\033[1;36m"
green="\033[0;32m"
@RakshithNM
RakshithNM / ixxing.md
Last active January 5, 2022 18:12
how to paste code from vim to online pastebin ix.io
  1. Create a folder called ~scripts in your home directory.

  2. In the directory create a file called ix.

  3. Add the following script to the file

#!/bin/bash

if [ -n "$1" ]; then
curl "ix.io/$1" 2>/dev/null
@RakshithNM
RakshithNM / array-reduce.js
Last active March 26, 2021 10:32
array reduce problems
/*
* Problem one
* Total of all numbers in an array
*/
const myArray1 = [1, 2, 3, 4, 5, 6, 7];
const reducedArray = myArray1.reduce((a, b) => a + b, 0)
console.log("+++++++++++++++++Problem one+++++++++++++++++++")
console.log(reducedArray);
package main
import "fmt"
type node struct {
data int
nextnodepointer *node
}
type linkedList struct {
package main
import "fmt"
type node struct {
data int
nextnodepointer *node
}
type linkedList struct {
package main
import "fmt"
type node struct {
data int
nextnodepointer *node
}
type linkedList struct {
package main
import "fmt"
type node struct {
data int
nextnodepointer *node
}
type linkedList struct {