LeetCode Jewels and Stones Explained - Java

preview_player
Показать описание


Preparing For Your Coding Interviews? Use These Resources
————————————————————

Other Social Media
----------------------------------------------

Show Support
------------------------------------------------------------------------------

#coding #programming #softwareengineering
Рекомендации по теме
Комментарии
Автор

@NickWhite The algorithm in which you used for this solution is actually not linear. IndexOf method used inside the for loop uses a linear search algorithm. Therefore, the time complexity is O(s * j) with s being the string and j being the jewels. I solved the question using a hashtable and linear search. I believe the space and time trade-off was worth it. Maybe there is a better solution out there.

KhalifaYakub
Автор

Time Complexity is not O(n). It is O(mn)

ayusharora
Автор

Thank you so much!!! Much love to you!

nasara
join shbcf.ru