1202. Smallest String With Swaps - Day 27/30 Leetcode April Challenge

preview_player
Показать описание
Larry solves and analyzes this Leetcode problem as both an interviewer and an interviewee. This is a live recording of a real engineer solving a problem live - no cuts or edits!

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

I liked the way of categorising the indices as equivalent classes but I wasn’t even able to figure out that this question requires union find, so how to improve this thing because if we don’t know that what to use in that problem we won’t be able to solve it

Sandeep-zddq
Автор

my first intuition was to do BFS, record the lexigraphicaly smallest string along the way, until all nodes are exhausted

antoniowong
Автор

That mistake in union find is pretty common.
Have done it multiple times 😂
Got to know about other approach of DSU.
My solution was of DFS on connected components.

Live-hhli
visit shbcf.ru