Skip to content

Instantly share code, notes, and snippets.

View kevinwucodes's full-sized avatar

Kevin Wu kevinwucodes

View GitHub Profile
@kevinwucodes
kevinwucodes / readme.md
Last active September 22, 2021 17:53
daily coding problem #1: Given a list of numbers and a number k, return whether any two numbers from the list add up to k

This problem was recently asked by Google.

Given a list of numbers and a number k, return whether any two numbers from the list add up to k.

For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.

function isAddedNumberInArray(inputAry, n) {
  return (
    inputAry
@kevinwucodes
kevinwucodes / readme.md
Last active October 17, 2020 15:42
daily coding problem #2: Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.

This problem was asked by Uber.

Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.

For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].

function aryTransform(input) {
@kevinwucodes
kevinwucodes / sql.sql
Last active November 6, 2018 23:35
sql - learn - string aggregation prior to STRING_AGG()
--https://stackoverflow.com/questions/31211506/how-stuff-and-for-xml-path-work-in-sql-server
--https://stackoverflow.com/questions/273238/how-to-use-group-by-to-concatenate-strings-in-sql-server
;with colors as (
select id, name, color
from (
values
(1, 'kevin', 'blue')
,(2, 'kevin', 'red')
,(3, 'aria', 'pink')
@kevinwucodes
kevinwucodes / sql.sql
Created October 23, 2018 21:19
sql learning - hashing a row with specific columns in that row
;with names as (
select name, color
from (
values
('kevin','blue')
,('kevin','blue')
,('kevin','red')
) x (name, color)
)
select
@kevinwucodes
kevinwucodes / sql.sql
Created October 18, 2018 16:48
sql - learn pivoting
--;with q as (
-- select id, color, intensity
-- from (
-- values
-- (1,'blue',4)
-- ,(2,'red',5)
-- ,(3,'blue',7)
-- ,(4,'blue',1)
-- ,(5,'yellow',3)
-- ) colors (id, color, intensity)
@kevinwucodes
kevinwucodes / sql.sql
Created October 17, 2018 22:15
sql - learn row_number() with case when
select
ranked = case
when color <> 'black' then
row_number() over (partition by
case when color <> 'black' then 1 end
,person
order by (select null)
)
else null
@kevinwucodes
kevinwucodes / sql.sql
Last active October 17, 2018 22:08
SQL - learn grouping
;with persons as (
select id, name, gender, color
from (
values
(1,'kevin','m','blue')
,(2,'owen','m','blue')
,(3,'wendy','f','pink')
,(4,'emrys','m','black')
,(5,'aria','f','brown')
) q (id, name, gender, color)
@kevinwucodes
kevinwucodes / readme.md
Created August 5, 2018 01:46
Understanding JavaScript Functions

Today, I got stumped. Let's get unstumped.

While watching André Staltz's excellent Two Fundamental Abstractions talk, he shared something like this about 24 minutes into his talk:

const a = b => b(10)

a(x => console.log(x))
@kevinwucodes
kevinwucodes / readme.md
Last active October 19, 2017 19:45
puppeteer v0.12 experiments

page.evaluate

const a = await page.evaluate(selector => document.querySelector(selector).textContent, WELCOMETAG_SELECTOR)

page.$eval

const b = await page.$eval(WELCOMETAG_SELECTOR, stuff => stuff.textContent)
@kevinwucodes
kevinwucodes / using-debounce.md
Last active October 16, 2017 01:11
ways to use debounce in React