Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Time complexity should be further reduced

lenkadan

Oct 18, 2025

Time complexity O(n+m) should be further reduced. O (n) is the length of jewels, where each character is a unique jewel as per problem description.

As the input is limited by the finite number of letters of English alphabet and the uniqueness of jewels will not make the length of Jewels string grow by duplicating characters, this input should be considered a constant as it does not scale. So O(n+m) where n is constant, should be reduced to O(m) for m = length of stones string

0

0

Comments
Comments

On this page