Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
All O'one Data Structure
Bookmark
Brute Force
Count Buckets
Input
Example 1
Example 2
Example 3
Custom
operations
=
[AllOne, inc, inc, inc, inc, inc, dec, getMaxKey, getMinKey]
,
values
=
[null, a, b, b, a, a, b, null, null]
Operation
—
Result
—
Count Buckets (Doubly Linked List)
HEAD (0)
TAIL (∞)
keyToNode Map
(empty)
Operation
—
Result
—
Count Buckets (Doubly Linked List)
HEAD (0)
TAIL (∞)
keyToNode Map
(empty)
Operation
inc("a")
Result
—
Count Buckets (Doubly Linked List)
HEAD (0)
Count: 1
{a}
TAIL (∞)
keyToNode Map
Key
Count
"a"
1
Operation
inc("b")
Result
—
Count Buckets (Doubly Linked List)
HEAD (0)
Count: 1
{a, b}
TAIL (∞)
keyToNode Map
Key
Count
"a"
1
"b"
1
Operation
inc("b")
Result
—
Count Buckets (Doubly Linked List)
HEAD (0)
Count: 1
{a, b}
Count: 2
{}
TAIL (∞)
keyToNode Map
Key
Count
"a"
1
"b"
1
Operation
inc("a")
Result
—
Count Buckets (Doubly Linked List)
HEAD (0)
Count: 1
{a}
Count: 2
{b}
TAIL (∞)
keyToNode Map
Key
Count
"a"
1
"b"
2
Operation
inc("a")
Result
null
Count Buckets (Doubly Linked List)
HEAD (0)
Count: 2
{b, a}
TAIL (∞)
keyToNode Map
Key
Count
"a"
2
"b"
2
Operation
inc("a")
Result
—
Count Buckets (Doubly Linked List)
HEAD (0)
Count: 2
{b}
Count: 3
{a}
TAIL (∞)
keyToNode Map
Key
Count
"a"
3
"b"
2
Operation
dec("b")
Result
—
Count Buckets (Doubly Linked List)
HEAD (0)
Count: 1
{}
Count: 2
{b}
Count: 3
{a}
TAIL (∞)
keyToNode Map
Key
Count
"a"
3
"b"
2
Operation
getMaxKey()
Result
—
Count Buckets (Doubly Linked List)
HEAD (0)
Count: 1
{b}
Count: 3
{a}
TAIL (∞)
keyToNode Map
Key
Count
"a"
3
"b"
1
Operation
getMinKey()
Result
"b"
Count Buckets (Doubly Linked List)
HEAD (0)
Count: 1
{b}
Count: 3
{a}
TAIL (∞)
keyToNode Map
Key
Count
"a"
3
"b"
1
algo
master
.
io
Step:
Initialize AllOne data structure with head and tail sentinels
0 / 52
Input
Example 1
Example 2
Example 3
Custom
operations
=
[AllOne, inc, inc, inc, inc, inc, dec, getMaxKey, getMinKey]
,
values
=
[null, a, b, b, a, a, b, null, null]
0 / 52
algo
master
.
io
Step:
Initialize AllOne data structure with head and tail sentinels