Google | Phone Screen | L4 | Find Nodes

Anonymous User
2962
Feb 19, 2024

Given some input like this
This is very funny
image

which forms the following tree

image

We are given this tree and the string to search for,Return the list of consecutive text nodes that contain the search string.
"hi"-> node 4
"his is very" -> nodes 4 and 5
"is very fun" -> 5 and 6

Public interface Node{
@Nullable String getText();
Node[] getChildren();
@Nullable Node getParent();
Boolean isText();
}

Public List fineText(Node head, String Search)
{}

Comments (6)