Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Why is Space Complexity for the fruit basket not O(K) like the parent problem? I...

ag

Sep 6, 2022

Why is Space Complexity for the fruit basket not O(K) like the parent problem? I didn't get the below part -> "The algorithm runs in constant space O(1)O(1) as there can be a maximum of three types of fruits stored in the frequency map."

0

0

Comments
Comments
Design Gurus
Design Gurus3 years ago

For this problem, K=3 (for the three fruit types).

Hence, the space complexity will be:

O(K) => O(3) => O(1)

On this page