Following are going to be covered in this post:
Overview of Data Structures
Reference: https://www.geeksforgeeks.org/data-structures/
Data structure is a way of organizing data so that it can be used effectively. It is used to reduced the time and space complexity for different tasks.
[LeetCode] 0101 Symmetric Tree
Symbols count in article: 2.4k Reading time ≈ 2 mins.
Symmetric Tree
LeetCode - 0101 Symmetric Tree
https://leetcode.com/problems/symmetric-tree/
Problem Description
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1, 2, 2, 3, 4, 4, 3] is symmetric:
1 | 1 |
But the following [1, 2, 2, null, 3, null, 3] is not:
1 | 1 |
[LeetCode] 0070 Climbing Stairs
Symbols count in article: 1.1k Reading time ≈ 1 mins.
Climbing Stairs
LeetCode - 0070 Climbing Stairs
https://leetcode.com/problems/climbing-stairs/
Problem Description
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Note: Given n will be a positive integer.
Example 1:
Input: 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps
Most Frequent Element in an Array
Symbols count in article: 1.1k Reading time ≈ 1 mins.
Most Frequent Element in an Array
Problem Description
Given an array, find the most frequent element in it. If there are multiple elements that appear maximum number of times, print any one of them.
Example:
Input: [1, 3, 2, 1, 4, 1] Output: 1 Explanation: 1 appears three times in an array which is maximum frequency
Input: [10, 20, 10, 20, 30, 20, 20] Output: 20