Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Ransom Note
Bookmark
Brute Force
Sorting
Counting
Input
Can build
Not enough
Missing letter
Exact match
Custom
ransomNote
=
cat
,
magazine
=
attack
mag
note
a
t
t
a
c
k
no counting — search and cross out for each note letter
c
a
t
mag
note
a
t
t
a
c
k
no counting — search and cross out for each note letter
c
a
t
mag
note
i
a
t
t
a
c
k
magazine[0] ≠ 'c', keep scanning
c
a
t
j
mag
note
i
a
t
t
a
c
k
magazine[1] ≠ 'c', keep scanning
c
a
t
j
mag
note
i
a
t
t
a
c
k
magazine[3] ≠ 'c', keep scanning
c
a
t
j
mag
note
i
a
t
t
a
c
k
cross out magazine[4] and move to the next note letter
c
a
t
j
mag
note
a
t
t
a
c
k
need 'a', scan the magazine from index 0
c
a
t
j
mag
note
i
a
t
t
a
c
k
cross out magazine[0] and move to the next note letter
c
a
t
j
mag
note
i
a
t
t
a
c
k
magazine[0] ≠ 't', keep scanning
c
a
t
j
mag
note
i
a
t
t
a
c
k
magazine[1] == 't' — found it
c
a
t
j
mag
note
a
t
t
a
c
k
c
a
t
return
true
algo
master
.
io
Step:
For each note letter, search the magazine and cross out a match
0 / 15
Input
Can build
Not enough
Missing letter
Exact match
Custom
ransomNote
=
cat
,
magazine
=
attack
0 / 15
algo
master
.
io
Step:
For each note letter, search the magazine and cross out a match