Why is time complexity of fruit basket O(N + N)? There is an outer for loop and inner while loop. Outer loop iterates through each character, and inner while loop processes the entire map for each iteration. So shouldn’t this be O(N^2)?
I realized i’m looking at javascript solution and perhaps other implementations are more efficient, but at least for javascript the time complexity looks off
Course: Grokking the Coding Interview: Patterns for Coding Questions - Learn Interactively
Lesson: Fruits into Baskets (medium) - Grokking the Coding Interview: Patterns for Coding Questions
Course: Grokking the Coding Interview: Patterns for Coding Questions - Learn Interactively
Lesson: Fruits into Baskets (medium) - Grokking the Coding Interview: Patterns for Coding Questions