Trie Introduction - Advanced Data Structures / Trie

https://algo.monster/problems/trie_intro

Please correct if I am wrong

Line 10: “.insert” has 2 parameter → 1st index where we need to insert the element and 2nd is the element itself, but here why are we inserting the whole “s” and then the index position for that s?

We are not inserting “s” as a whole. We pass “s” together with the index so we know which element of the s-collection needs to be added to the tree

https://leetcode.com/problems/implement-trie-prefix-tree/solution/