BANKPASS-editorial

PROBLEM LINK:

Practice
Contest

DIFFICULTY:

EASY-MEDIUM

PREREQUISITES:

Trie

PROBLEM:

Problem: Given a list of passwords (word) you need to tell whether any word is the prefix of any other word in the list.

EXPLANATION:

First of all I would like to enlighten that some of the contestents have solved the problem by just sorting them and finding the substring due to weak test cases. But the problem was intended to be solved using the data structure trie. You are given a list of words; you need to find if any word is the prefix of another word in the list. You can do so by inserting each given passwords in the trie and simultaneously checking if insertion of the password makes conflict with the condition, if so then print “vulnerable” else print “non vulnerable”. Remember to scan all the words even if the conflict occurs in between.

AUTHOR’S AND TESTER’S SOLUTIONS:

Author’s solution can be found here.

2 Likes