e
b
1,213,5 6 8,4
Arr
expected output
Out
1 4,425,36164181
3,1
1,23
12 22 32
2.3
t
t
1 4,9
4,1 4,9
Unoptimal solution
3
I
1
I c nationtries
2,3
c
É
optimal solution
I
0,010,0
Create
an array
theoriginalarray
filled with Placeholder zeros that is the same length as
two sum
save
valvestin hashmap at enumerate through
tuningthe targetand
You want savethediffrenceinto a var or
Then
array
mapthenreturn
difference is in thewash
Youwant to see if the
subtracting bythe
current value
Validate subsequence
Use Pointers to fins
Set one
Update
array
elements
array
5,1 28,25 6
Seq
116
1
1 81101
to
Pointer in both array
seaIdx when seq element is found in
until Seattle
is
length of
Sell
Create a hashmap that will
hold
the scores for the teams
hold the current
will
a
var
that
create
bestteam
competition for intel
enumerate through the
define home and away
results Index
define
define the
teams
winningteam with theresults
Update scoresdictionart
Update current best if needed
and competitions
3 Sun
Output need
to
array
be
arras
of
target O
12,311,2
8,6
6,5
u
r
array
sorted
Oneumerate through
if
check
current
number
current number
initiate our
the
8
I
two pointers with
last
Igt yet ya
if
sum greater more right
if
sum lesser
move
sum equal
append and more
if
while left is
return output
used as
before
the nett index in array and
But
arrant
inset in the
sum
was
sorted
12.31142
a
Erm left
left
left
same nun as previous move left
6 s
8,6
right
loop here
start while
Ci Bi Citi
Check
a
10
213,314,0
I
array
nave
longestPeak
6,5
3
peak
is
book Value to check if numbers is Peak
if not a peak increment i
Make left index war
i
we
É
know the valve next to i is lower
e
as long as
as its lowerthan the value
left intact and as long
lettin I
same for right 120 but opposite
compute cur Peak
left I2x
right Idt
I
mat longest Curr
is right Idt
ya
ÉÉIs we can keep decrenti
in
our left index is
longest
1
Class Photos
ret 6,912.4 is
blue 5.811,304,4
Sort both arrays
arras has a grater current
lowest
Check
and
loopthrough
so return false
array
ist
the
larger
than the value in
value
Sum of
linked list
do
input
4
9
4
math
for
y
addition
5
2
out
create dummy note to keep track
of new linked list
Note Var to keep track
create current
2 4
0
10
Val
9 01110
Carry 2
2tttaarri
IJ.no
carry
Val
10
of
head
last vote creates
9
is
2,314
1
45532
12367
7,6 3,21
213,5 5,9
I I
7532
I
6
5 3,2
K
A
113
Ka
s
21
ks
IG
ol
47
61
1
3 E
L
R
3,1 4
2,277,4
i
r
2
Branch
Suns
in binary tree
branches
all
of
sum
1
15,16 18,10 a
8
I
8610
recursive call with running sum
NewRunning
runningsunt note value
Node if so append newRunning sum
a
leaf
is
Note
nose
Check if cur
is leaf
to sums thenreturn
Nose Risa
Node left and
If not a leafNode callfunction with
has one child Just
only
Node
if
edge case
return is node is None
Return
Note depth
recusirl
64 having our function take a
We can do this deptht recusion on leftNote recursion on right note
depth Val
O and returning
Invert binars
tree
recusive
switch
right nodes
right
with
left
then
call
recursion on left and
Just return is node is None
one
child
has
only
Node
edge case if
si
É
2 step
I way
problem
on il
solve
n zg
1
each sub
once
2
É
innit
ours
xEE EIIDn.n
One I One two
3
2
I
one
two
2
one
two
3
2
1
one
2
two
S
3
O one
8
3
two
return one
MinCostClimbing Stairs
Cost lo is 2
jtootbourss
start at O or 1 in
S
Zord
extra
havealgoto
for
th
for range lens
Work
of the air
mn
then return min
cost o
cost i
Cost it 2
costfi
É
1Ti
Cost its
CIstIiti
COSI
Is
house robber
nuÉ 1 2 31
I
2
roles math
4
4
trout
roll in
8061 I O
t into
Crout rows n n
temp max ntrobl 8062
8061 I 8062
8062 temp
Ying
i
1 0
tempi
1
I
0
1
80612
8061
1,2 31
I
2 0
temp
1
8061
2
8062
112
271
I
1
1
3
temp 3
2
8061
3
8062
472
1,213
temp
4
8061
3
8062 4
1 2
324
696 at
g
middle of parinaron
want to start from
length
There is
11
res
for
ans then spread outwards
an Edgecase for even
Palindromes
Initiate both to i
rightantleftPointers as while they're inbounds and while
initiate
Str
they are a palindrome so SE
f
r
t1
cur Resler thenupdate result and result Len
and expand pointer outwards L I
for
ever palindromes
Rt 1
initiate
they
K and R in bounds and while
if
window size greater than Resler
and expand window
i
L
are
R
ith
while
Paindroms
update result and rester
map Len Str s to 1
incase stri s i
22,6
of
22
2
Ifs
good base as
one
2
Position
if y
2
there in string
I 27
i
been
there Ofstring orareas came
if i in di
returnapp
0
if Sfi
theres no way todecode
a stringthat starts with 0
return 0
res Lfs itt
if ittalents and sti
rest dfs it 2
LP Ii
res
return res
d
or Sf
2 an s it 1 in 0123456
I 12,3 4,100188
100 4
20011,3
nisei
in
t I
til
set
0
2
4,5 6,710,12
É
6É
Map
j
I
I
hotel to copy of Note
in hashmap
When
I
Wang
we'll
see
that
its neighbor
ng
COPY I Node note
hashmafnote I copy
rat
neighbors to get
Loop through
original rate
from
neighbors
Copt neighbors append 28s re
isar
copy of
for dfs on
noses
neighbor
uncourses
L
It
reree Cloy
orereq
1011
feet more
1.3
0,2
1,4
3.4
fty
I
item
2
I
3
4,3 9,014.1
4th
I
heap
2,2
1,3
19
2 2
k
it
3 3
2 2
to
heap
1 10,113
8
21
unt
1 3
run 2
12
1,203
median
2,4
1,3
1,2 3,4
23
3 CREEEDID
I DIJID
2
2.5
Koko eating bananas
are
every
try
piles
is to until alltimefor n
bruteforcenumber required
in
gone
I
K
3 6,711
If we take
every pice in
so
we can
h 8
the pile we can eat
1 hour
1
a
try
si p
maxie
p
timing
range
we can do binary search on the k
compexit
time
better
a
to get
C O logmatte
3 6 7,113
Piles
1
K
i
2
2
1 2,3141
a
h
6n
P
8
16,7 8 9 10111
mis ice
112 46
3 G
I
3 4
2
g
I
Lir
L
res
r
mat piles
r
while L c
12
Hr
K
0
hours
for p in
piles
math Ceil
ti
hours
if
hours L
h
rest minfres
r
else
LI
return res
k
1088h
k
Kth
K
Pla
yes
because
y
67
Kth largest element in array
Can't sort because
I
it wousbe alogn time
time
a heap in O n
can
heap
You
create
You can use a max
numbersnegative
an the
In Pitman Youcan'tcreate a mannear so youmake
then Youwant to popfromtheheap k times to gettheanswer
mis wi
tht
If youuse aquickselectalgorithmwhichwillbedone inocitiming
outworsecase is 0 d
3
R
3
2
k2
s
I
6
pivot
wi
goes
right
that
what
value
M
and
left
he
choose
on
naves
onpureeachvalvetothepivotnaive
pivotgoesontheleftside
nothinglessthan or equaltothe
find avalvethat islessthanor equal to
we
et a pivot pointerso that anytime
wherepointeris an thenincrementthepointer
e pivotthenwe canputthevalve