Abstraction is an OOPS concept to construct the structure of the real world objects. During this construction only the general states and behaviors are taken and more specific states and behaviors are left aside for the implementers.
Encapsulation is an OOPS concept to create and define the permissions and restrictions of an object and its member variables and methods. A very simple example to explain the concept is to make the member variables of a class private and providing public getter and setter methods. Java provides four types of access level modifiers: public, protected, no modifier and private.
- Find height of a tree.
- Easy, return 1 + max(maxDepth(left), maxDepth(right))
 
 - Find all paths to leaves.
- Easy but check string builder stuff.
 
 - K_th smallest.
- Traverse left using a stack until there is no left, the leftmost element is the smallest, then start traversing right, decrementing k with every step.
 
public int kthSmallest(TreeNode root, int k) {
 
