This file contains 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
version: '3.7' | |
services: | |
web: | |
network_mode: host | |
image: >- | |
tailscale/tailscale:v1.66@sha256:cf8e97667e8be250caaed88694cec0befe11040bbd5a3de3b33086cc52ef4eb1 | |
restart: on-failure | |
stop_grace_period: 1m | |
environment: | |
- TS_EXTRA_ARGS=--advertise-exit-mode --exit-node-allow-lan-access |
This file contains 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
/** | |
* @param {number} m | |
* @param {number} n | |
* @return {number} | |
*/ | |
function uniquePaths(m, n) { | |
let arr = []; | |
for (let i = 0; i <=m; i++) { | |
arr.push(new Array(n + 1).fill(0)); | |
} |
This file contains 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
/** | |
* Definition for a binary tree node. | |
* function TreeNode(val, left, right) { | |
* this.val = (val===undefined ? 0 : val) | |
* this.left = (left===undefined ? null : left) | |
* this.right = (right===undefined ? null : right) | |
* } | |
*/ | |
/** | |
* @param {number[]} nums |
This file contains 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
/** | |
* Definition for a binary tree node. | |
* function TreeNode(val, left, right) { | |
* this.val = (val===undefined ? 0 : val) | |
* this.left = (left===undefined ? null : left) | |
* this.right = (right===undefined ? null : right) | |
* } | |
*/ | |
/** | |
* @param {TreeNode} root |
This file contains 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 shortestPathBinaryMatrix(grid) { | |
const directions = [ | |
[1, 0], | |
[-1, 0], | |
[0, 1], | |
[0, -1], | |
[1, 1], | |
[1, -1], | |
[-1, 1], | |
[-1, -1], |
This file contains 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 uncommonWords(s1, s2) { | |
const words1 = s1.split(' '); | |
const words2 = s2.split(' '); | |
const freq = new Map(); | |
for (const word of words1) { | |
freq.set(word, (freq.get(word) || 0) + 1); | |
} |
This file contains 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
/** | |
* @param {string[]} strs | |
* @return {string} | |
*/ | |
function longestCommonPrefix(strs) { | |
if (strs.length === 0) { | |
return ""; | |
} | |
let prefix = strs[0]; |
This file contains 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
/** | |
* @param {number[]} nums | |
* @param {number} target | |
* @return {number[]} | |
*/ | |
function twoSum(nums, target) { | |
let mp = new Map() | |
for (let i = 0; i < nums.length; i++) { | |
let diff = target - nums[i] |
This file contains 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 topKFrequentWords(words, k) { | |
const freq = new Map(); | |
for (const word of words) { | |
if (!freq.has(word)) { | |
freq.set(word, 1); | |
} else { | |
freq.set(word, freq.get(word) + 1); | |
} | |
} |
This file contains 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 RandomizedSet { | |
constructor() { | |
this.set = new Map(); | |
this.array = []; | |
} | |
insert(val) { | |
if (this.set.has(val)) { | |
return false; | |
} |
NewerOlder