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

0% completed

Vote For New Content
Can someone help me with the time/space complexity of this solution?

Anthony DiFede

Nov 17, 2022

Can someone help me with the time/space complexity of this solution?

Image

1

0

Comments
Comments
D
Douglas 3 years ago

The time complexity is O(2M (creating two Hash Maps) + M*N (in the worst case all letters are wrong and you need to remake the second HashMap with a cost of O(M) in every one of the N iterations) ) The space complexity in the worst case is O(2M), when there's no repeate...

On this page