In the last post we learnt about Binary Search Trees and basic operations like insert and search on them. In this post we’ll learn about some complex operations on them.
Alansh has to travel through a road having hills of different heights. Also each hill has a cave to pass through it, to avoid travelling extra distance of a hill. Alansh wants to travel through this road by taking at most K caves.
Given the roots of two binary trees root and rootSub, check if there is a subtree of root with the same structure and node values as rootSub.
A subtree of a tree T is a tree S consisting of a node in T and all of its descendants in T.
In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters.
A Linked List is a data structure in which the objects are arranged in a linear order. Unlike Arrays, you cannot access any element directly through its index.