973. K Closest Points to Origin

Medium : https://leetcode.com/problems/k-closest-points-to-origin/solution/

We have a list of `points`

on the plane. Find the `K`

closest points to the origin `(0, 0)`

.

(Here, the distance between two points on a plane is the Euclidean distance.)

You may return the answer in any order. The…

https://leetcode.com/problems/repeated-substring-pattern/

Easy But **tough** for me as I do not know two of the algorithms

Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. …

Medium — Leetcode: https://leetcode.com/problems/decoded-string-at-index/solution/

An encoded string `S`

is given. To find and write the *decoded* string to a tape, the encoded string is read **one character at a time** and the following steps are taken:

- If the character read is a letter, that letter is written onto the tape.
- …

Medium(https://leetcode.com/problems/populating-next-right-pointers-in-each-node/submissions/)

You are given a **perfect binary tree** where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:

`struct Node {`

int val;

Node *left;

Node *right;

Node *next;

}

Populate each next pointer to point to its next…

Medium : https://leetcode.com/problems/binary-tree-right-side-view/

Given a binary tree, imagine yourself standing on the *right* side of it, return the values of the nodes you can see ordered from top to bottom.

**Example:**

Input:[1,2,3,null,5,null,4]Output:[1, 3, 4]Explanation:1 <---

/ \

2 3 <---

\ \

5 4 <---

**…**

Iterative — Easy : https://leetcode.com/problems/symmetric-tree/

Recursive — Medium [ very important and intuitive]

Hint : 1. A Tree is symmetric to itself. So if you implement a function which accepts two trees to check for symmetry, you can start the first call of the function with symmetric(root, root).

**Problem Statement:**

…

Easy

Sum of Left Leaves

Easy : https://leetcode.com/problems/sum-of-left-leaves/

Find the sum of all left leaves in a given binary tree.

**Example:**

3

/ \

9 20

/ \

15 7There are two left leaves in the binary tree, with values9and15respectively. Return24.

Iterative Code:

`#…`

Medium- Hard, https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/solution/

Given a binary tree, return the *zigzag level order* traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).

**During interview:**

- Its good to point out the differences in the space complexity of the BFS (using…

Following the previous post on BF traversal of BSTrees, here is another cool problem often can be easily described using two different data structures. A dictionary and a Tree at play. Please read along ..

Top view of a binary tree is the set of nodes visible when the tree…

In this post, I will summarize a Binary’s Search Trees (BST)s, level order traversal. I picked this problem from HackerRank Site and feel like, its been touch based so much every where it needs a place where the problem and solution can be easily searched and read. …