shouldDeleteCurrentNode should also check if the current node is not having other word isEndOfWord as true.
Author: AamirBCreated Jul 10, 2020Updated Jul 10, 2020
if(shouldDeleteCurrentNode){
current.children.remove(word.charAt(index));
//return true if no mappings are left in the map.
return current.children.size() == 0 && !current.isEndOfWord;
}Steps: Add "Aamir" Add "Aami" delete "Aamir" As per the current code this will also delete "Aami"
Source: mission-peace/interview