# K Closest Points to Origin — Leetcode Medium

`Input: points = [[1,3],[-2,2]], K = 1Output: [[-2,2]]Explanation: The distance between (1, 3) and the origin is sqrt(10).The distance between (-2, 2) and the origin is sqrt(8).Since sqrt(8) < sqrt(10), (-2, 2) is closer…`

# 2. Divisors + Rabin-Karp

`Input: "abab"Output: TrueExplanation: It's the substring "ab" twice.`
`Input: "aba"Output: False`
`Input: "abcabcabcabc"Output: TrueExplanation: It's the substring "abc" four times. (And the substring "abcabc" twice.)`

# Decoded String at Index : Array + math

• If the character read is a letter, that letter is written onto the tape.
• If the character read is a digit (say `d`), the entire current tape is repeatedly written `d-1` more times in total.
`Input: S = "leet2code3", K…`

# Populating Next Right Pointers in Each Node

`struct Node {  int val;  Node *left;  Node *right;  Node *next;}`
• You may only use constant extra space.
• Recursive approach is fine, you may assume implicit stack space does not count as extra space…

# OVERVIEW BFS, Recursive DFS with Example : Binary Tree Right Side View

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

# LevelOrderTraversal : Symmetric Tree

`1   / \  2   2 / \ / \3  4 4  3`
`1   / \…`

# Sum of left children — Preorder traversal

`    3   / \  9  20    /  \   15   7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.`
`# Definition for a binary tree node.# class TreeNode:#     def __init__(self, val=0, left=None, right=None):#         self.val = val#         self.left = left#         self.right = rightclass…`

# Binary Tree Zigzag Level Order Traversal

1. Its good to point out the differences in the space complexity of the BFS (using a queue) and DFS (recursion ) approaches.
2. Both solutions are below.
`    3   / \  9  20    /  \   15   7`
`[  [3],  [20,9],  [15,7]]`
1. It is quite evident that we are traversing one level at…

# For example:

`…`

## Technical Interviews Preparation

Currently preparing for interviews

Get the Medium app