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
import time | |
Ts = [] | |
Ns = [] | |
for multiple in range(1, 11): | |
N = 10 * multiple | |
Ns.append(N) | |
STR_LENGTH = 3000 | |
root = Node('a'*STR_LENGTH) | |
current = root | |
N_trials = 10 |
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
// this function allows us to stop our code for |ms| milliseconds. | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
// I've put our main code into this function. | |
async function addPeople() { | |
ul = $('ul.mn-pymk-list__cards')[0]; | |
firstLi = ul.querySelector('li'); | |
count = 0; // this is the count of how many people you've added |
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 Solution: | |
# NOTE: extra space: O(m), time: O(n + m) | |
def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: | |
""" | |
Do not return anything, modify nums1 in-place instead. | |
""" | |
nums1_copy = [None] * m | |
for i in range(m): | |
nums1_copy[i] = nums1[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
/** | |
* @param {number[]} nums1 | |
* @param {number} m | |
* @param {number[]} nums2 | |
* @param {number} n | |
* @return {void} Do not return anything, modify nums1 in-place instead. | |
*/ | |
// NOTE: extra space: O(m), time: O(n + m) | |
var merge = function(nums1, m, nums2, n) { | |
nums1Copy = Array(m); |
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
var helper = function(current, last, target) { | |
if (current == target) { | |
return 0; | |
} else if (current > target) { | |
return Infinity; | |
} | |
let option1 = last != current ? helper(current, current, target) + 1 : Infinity; | |
let option2 = last != 0 ? helper(current + last, last, target) + 1 : Infinity; | |
if (option1 < option2) { |
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) { | |
* this.val = val; | |
* this.left = this.right = null; | |
* } | |
*/ | |
/** | |
* @param {TreeNode} root | |
* @return {boolean} |
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 | |
* @return {number} | |
*/ | |
var rob = function(nums) { | |
return helper(nums, 0); | |
}; | |
var helper = function(nums, current) { | |
if (current > nums.length) { |
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 | |
* @return {number} | |
*/ | |
var rob = function(nums) { | |
let memo = Array(nums.length); | |
return helper(nums, 0, memo); | |
}; | |
var helper = function(nums, current, memo) { |
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[]} A | |
* @return {boolean} | |
*/ | |
var validMountainArray = function(A) { | |
if (A.length < 3) { | |
return false; | |
} | |
let current = A[0]; | |
let i = 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 {number[]} nums | |
* @return {boolean} | |
*/ | |
var increasingTriplet = function(nums) { | |
let currentMin = nums[0]; | |
let minWithSmaller = Infinity; | |
for (let i = 1; i < nums.length; i++) { | |
if (nums[i] > minWithSmaller) { |
OlderNewer