👷♂️
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 communityFollowers = { | |
| C1: ["F1", "F3"], | |
| C2: ["F1", "F2"], | |
| C3: ["F2"], | |
| C4: ["F3"], | |
| } | |
| const followedCommunities = { | |
| F1: ["C1", "C2"], | |
| F2: ["C2", "C3"], |
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
| function miniMaxSum(arr) { | |
| arr.sort((a, b) => a - b) // to avoid 12 being before 2 | |
| // edge case with just one element | |
| if (arr.length === 1) { | |
| return console.log(arr[0], arr[0]) | |
| } | |
| let min = Infinity; | |
| let max = 0 |
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 data = [-2, 45, 0, 11, -9] | |
| let cursor = 0 | |
| while (cursor < data.length) { | |
| let min = data[cursor] | |
| let minPosition = cursor | |
| for(let i = cursor; i < data.length; i++) { | |
| if (data[i] < min) { | |
| min = data[i] | |
| minPosition = i |
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
| // Test if the given set of brackets is balanced or not. | |
| const data = '{{}}{)([][]'.split('') | |
| // Initiate the stack with the first element | |
| const stack = [data[0]] | |
| for (let c = 1; c < data.length; c++) { | |
| const topElement = stack[stack.length - 1] | |
| if ( | |
| (topElement == '{' && data[c] == '}') || |
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
| // You have three Arrays. | |
| const A = [2, 5, 3, 2, 8,1] | |
| const B = [7, 9, 5, 2, 4, 10, 10] | |
| const C = [6, 7, 5, 5, 3, 7] | |
| // Make an array from this three arrays which elements is present in at least two array. | |
| const map = {} | |
| Array(A, B, C).forEach(arr => { | |
| // Eliminate duplicates from the same array, use Set for this purpose |
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
| /** | |
| * Graph :: BFS | |
| */ | |
| class Graph { | |
| constructor() { | |
| this.edges = [] | |
| } | |
| addEdge(v, w) { |
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
| function generateInput() { | |
| const input = [] | |
| for (var i = 0; i < 100; i++) { | |
| input.push(Math.ceil(Math.random() * 100)) | |
| } | |
| return input | |
| } | |
| // const input = generateInput().slice(0, 10) |
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
| import assert from "node:assert" | |
| const l1 = [1, 3, 6, 10] | |
| const l2 = [4, 5, 10, 12, 14] | |
| console.log("List 1:", l1) | |
| console.log("List 2:", l2) | |
| const result = [] |
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
| /** | |
| * This is a probe to work with AWS's Service map to dynamically get URL of backend API and invoke it. | |
| * No hardcoded values, but we can filter for specific namespace and services withing that namespace. | |
| */ | |
| const https = require("https") | |
| const ServiceDiscovery = require("aws-sdk").ServiceDiscovery | |
| const sd = new ServiceDiscovery() |
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
| # Put this somewhere in the ~/.zshrc file | |
| load-nvmrc() { | |
| local nvmrc_path="$(pwd -P)/.nvmrc" | |
| if [[ -a "$nvmrc_path" ]]; then | |
| local nvmrc_node_version=$(cat "${nvmrc_path}") | |
| if [ "$nvmrc_node_version" = "N/A" ]; then | |
| n latest |
NewerOlder