• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
February 01, 2024 |860 Views

PROBLEM OF THE DAY : 31/01/2024 | Insert and Search in a Trie

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Trie but also build up problem-solving skills.

In this problem, we have to complete the Insert and Search functions for a Trie Data Structure.

Insert: Accepts the Trie's root and a string, modifies the root in-place, and returns nothing.
Search: Takes the Trie's root and a string, returns true if the string is in the Trie, otherwise false.

Note: To test the correctness of your code, the code-judge will be inserting a list of N strings called into the Trie, and then will search for the string key in the Trie. The code-judge will generate 1 if the key is present in the Trie, else 0.

Example :

Input:
n = 8
list[] = {the, a, there, answer, any, by, bye, their}
key = the
Output: 1
Explanation: 
"the" is present in the given set of strings. 

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/trie-insert-and-search0651/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp-compiler/9693b744-344e-42a7-a93a-223f80a7408a