diff --git a/dsa-problems/leetcode-problems/0300-0399.md b/dsa-problems/leetcode-problems/0300-0399.md
index 974e35a03..252ff38e6 100644
--- a/dsa-problems/leetcode-problems/0300-0399.md
+++ b/dsa-problems/leetcode-problems/0300-0399.md
@@ -159,7 +159,7 @@ export const problems = [
"problemName": "324. Wiggle Sort II",
"difficulty": "Medium",
"leetCodeLink": "https://leetcode.com/problems/wiggle-sort-ii/",
- "solutionLink": "#"
+ "solutionLink": "/dsa-solutions/lc-solutions/0300-0399/wiggle-sort-ii"
},
{
"problemName": "325. maximum-size-subarray-sum-equals-k",
diff --git a/dsa-problems/leetcode-problems/0500-0599.md b/dsa-problems/leetcode-problems/0500-0599.md
index b18072f6d..cf5806cc3 100644
--- a/dsa-problems/leetcode-problems/0500-0599.md
+++ b/dsa-problems/leetcode-problems/0500-0599.md
@@ -275,10 +275,10 @@ export const problems =[
"solutionLink": "#"
},
{
- "problemName": "547. Friend Circles",
+ "problemName": "547. Number of Provinces",
"difficulty": "Medium",
- "leetCodeLink": "https://leetcode.com/problems/friend-circles",
- "solutionLink": "#"
+ "leetCodeLink": "https://leetcode.com/problems/number-of-provinces/",
+ "solutionLink": "/dsa-solutions/lc-solutions/0500-0599/number-of-provinces"
},
{
"problemName": "548. Split Array with Equal Sum",
diff --git a/dsa-solutions/lc-solutions/0300-0399/0324-wiggle-sort-ii.md b/dsa-solutions/lc-solutions/0300-0399/0324-wiggle-sort-ii.md
new file mode 100644
index 000000000..43e3bd869
--- /dev/null
+++ b/dsa-solutions/lc-solutions/0300-0399/0324-wiggle-sort-ii.md
@@ -0,0 +1,237 @@
+---
+id: wiggle-sort-ii
+title: Wiggle Sort II
+sidebar_label: 0324 - Wiggle Sort II
+tags:
+- Array
+- Divide and Conquer
+- Greedy
+- Sorting
+- Quickselect
+
+description: "This is a solution to the Wiggle Sort II problem on LeetCode."
+---
+
+## Problem Description
+Given an integer array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]....
+You may assume the input array always has a valid answer.
+
+### Examples
+
+**Example 1:**
+
+```
+Input: nums = [1,5,1,1,6,4]
+Output: [1,6,1,5,1,4]
+Explanation: [1,4,1,5,1,6] is also accepted.
+
+```
+
+**Example 2:**
+```
+Input: nums = [1,3,2,2,3,1]
+Output: [2,3,1,3,1,2]
+```
+
+### Constraints
+
+- `1 <= nums.length <= 5 * 10^4`
+- `0 <= nums[i] <= 5000`
+- It is guaranteed that there will be an answer for the given input nums.
+
+## Solution for Wiggle Sort II Problem
+### Approach
+#### Sorting the Array:
+- The first step is to sort the input array nums. This ensures that the elements are in non-decreasing order.
+- Sorting helps to easily pick the smallest and largest remaining elements in subsequent steps.
+#### Creating a Temporary Array:
+- A temporary array temp of the same size as nums is created to store the elements in a "wiggle" pattern.
+- An index variable j is initialized to point to the last element of the sorted nums array. This will help in filling the temporary array from the largest to the smallest element.
+#### Filling Odd Indices:
+- A loop runs from the index 1 to the end of the array with a step of 2 (i.e., 1, 3, 5, ...). This loop fills the odd indices of the temp array.
+- The largest remaining elements from nums are placed at these odd indices. The index j is decremented after placing each element.
+#### Filling Even Indices:
+- Another loop runs from the index 0 to the end of the array with a step of 2 (i.e., 0, 2, 4, ...). This loop fills the even indices of the temp array.
+- The largest remaining elements from nums are placed at these even indices. The index j is decremented after placing each element.
+- Copying Back to Original Array:
+- The temp array, now containing the elements in the desired "wiggle" order, is copied back to the original nums array.
+
+
+
+
+
+ #### Implementation
+ ```jsx live
+ function Solution(arr) {
+ function wiggleSort(nums) {
+ nums.sort((a, b) => a - b);
+ const temp = new Array(nums.length);
+ let j = nums.length - 1;
+ for (let i = 1; i < nums.length; i += 2) {
+ temp[i] = nums[j--];
+ }
+ for (let i = 0; i < nums.length; i += 2) {
+ temp[i] = nums[j--];
+ }
+ return temp;
+ }
+ const input = [1, 5, 1, 1, 6, 4];
+ const output = wiggleSort(input);
+ return (
+
+
+ Input:
+ {JSON.stringify(input)}
+
+
+ Output: {output.toString()}
+
+
+ );
+ }
+ ```
+
+ #### Complexity Analysis
+
+ - Time Complexity: $ O(nlogn) $ is the time complexity, where n is the size of array
+ - Space Complexity: $ O(n) $ , because of the Temp array we have taken.
+
+ ## Code in Different Languages
+
+
+
+ ```javascript
+ function wiggleSort(nums) {
+ nums.sort((a, b) => a - b);
+ const temp = new Array(nums.length);
+ let j = nums.length - 1;
+ for (let i = 1; i < nums.length; i += 2) {
+ temp[i] = nums[j--];
+ }
+ for (let i = 0; i < nums.length; i += 2) {
+ temp[i] = nums[j--];
+ }
+ for (let i = 0; i < nums.length; i++) {
+ nums[i] = temp[i];
+ }
+ }
+ ```
+
+
+
+
+ ```typescript
+ function wiggleSort(nums: number[]): void {
+ nums.sort((a, b) => a - b);
+ const temp: number[] = new Array(nums.length);
+ let j = nums.length - 1;
+
+ for (let i = 1; i < nums.length; i += 2) {
+ temp[i] = nums[j--];
+ }
+ for (let i = 0; i < nums.length; i += 2) {
+ temp[i] = nums[j--];
+ }
+
+ for (let i = 0; i < nums.length; i++) {
+ nums[i] = temp[i];
+ }
+}
+
+// Example usage
+ const input: number[] = [1, 5, 1, 1, 6, 4];
+ wiggleSort(input);
+ console.log(input); // Output might be [1, 6, 1, 5, 1, 4]
+ ```
+
+
+
+
+ ```python
+ def wiggle_sort(nums):
+ nums.sort()
+ temp = [0] * len(nums)
+ j = len(nums) - 1
+
+ for i in range(1, len(nums), 2):
+ temp[i] = nums[j]
+ j -= 1
+ for i in range(0, len(nums), 2):
+ temp[i] = nums[j]
+ j -= 1
+
+ for i in range(len(nums)):
+ nums[i] = temp[i]
+
+# Example usage
+input = [1, 5, 1, 1, 6, 4]
+wiggle_sort(input)
+print(input) # Output might be [1, 6, 1, 5, 1, 4]
+
+ ```
+
+
+
+
+ ```java
+ import java.util.Arrays;
+
+public class WiggleSort {
+ public static void wiggleSort(int[] nums) {
+ Arrays.sort(nums);
+ int[] temp = new int[nums.length];
+ int j = nums.length - 1;
+
+ for (int i = 1; i < nums.length; i += 2) {
+ temp[i] = nums[j--];
+ }
+ for (int i = 0; i < nums.length; i += 2) {
+ temp[i] = nums[j--];
+ }
+
+ System.arraycopy(temp, 0, nums, 0, nums.length);
+ }
+
+ public static void main(String[] args) {
+ int[] input = {1, 5, 1, 1, 6, 4};
+ wiggleSort(input);
+ System.out.println(Arrays.toString(input)); // Output might be [1, 6, 1, 5, 1, 4]
+ }
+}
+
+ ```
+
+
+
+
+ ```cpp
+ class Solution {
+public:
+ void wiggleSort(vector& nums) {
+ sort(nums.begin() , nums.end());
+ vectortemp(nums.size());
+ int j=nums.size()-1;
+ for(int i=1;i
+
+
+
+
+
+## References
+
+- **LeetCode Problem**: [Wiggle Sort II](https://leetcode.com/problems/wiggle-sort-ii/description/)
+
+- **Solution Link**: [LeetCode Solution](https://leetcode.com/problems/wiggle-sort-ii/solution)
+
diff --git a/dsa-solutions/lc-solutions/0500-0599/0547-number-of-provinces.md b/dsa-solutions/lc-solutions/0500-0599/0547-number-of-provinces.md
new file mode 100644
index 000000000..82fd090df
--- /dev/null
+++ b/dsa-solutions/lc-solutions/0500-0599/0547-number-of-provinces.md
@@ -0,0 +1,339 @@
+---
+id: number-of-provinces
+title: Number of Provinces
+sidebar_label: 0547 - Number of Provinces
+tags:
+- Depth-First Search
+- Breadth-First Search
+- Union Find
+- Graph
+description: "This is a solution to the Number of Provincess problem on LeetCode."
+---
+
+## Problem Description
+There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city c, then city a is connected indirectly with city c.
+A province is a group of directly or indirectly connected cities and no other cities outside of the group.
+You are given an n x n matrix isConnected where isConnected[i][j] = 1 if the ith city and the jth city are directly connected, and isConnected[i][j] = 0 otherwise.
+Return the total number of provinces.
+
+### Examples
+
+**Example 1:**
+
+```
+Input: isConnected = [[1,1,0],[1,1,0],[0,0,1]]
+Output: 2
+```
+
+**Example 2:**
+
+```
+Input: isConnected = [[1,0,0],[0,1,0],[0,0,1]]
+Output: 3
+```
+
+### Constraints
+- `1 <= n <= 200`
+- `n == isConnected.length`
+- `n == isConnected[i].length`
+- `isConnected[i][j] is 1 or 0.`
+- `isConnected[i][i] == 1`
+- `isConnected[i][j] == isConnected[j][i]`
+
+## Solution for Number of Provinces
+
+### Intuition ans Approach
+- To find the solution, we conceptualize the cities and the connections between them as a graph, where each city is a node and each direct connection is an edge. Now, the problem translates to finding the number of connected components in the graph. Each connected component will represent one province.
+
+- To do this, we use Depth-First Search (DFS). Here's the intuition behind using DFS:
+
+- We start with the first city and perform a DFS to mark all cities that are connected directly or indirectly to it. These cities form one province.
+- Once the DFS is completed, we look for the next city that hasn't been visited yet and perform a DFS from that city to find another province.
+- We repeat this process until all cities have been visited.
+- Each time we initiate a DFS from a new unvisited city, we know that we've found a new province, so we increment our province count. The DFS ensures that we navigate through all the cities within a province before moving on to the next one.
+- By doing the above steps using a vis (visited) list to keep track of which cities have been visited, we can effectively determine and count all the provinces.
+
+
+
+
+#### Implementation
+
+```jsx live
+function Solution() {
+ function dfs(root, vis, adj) {
+ vis[root] = 1;
+ for (let val of adj[root]) {
+ if (vis[val] === 0) {
+ dfs(val, vis, adj);
+ }
+ }
+}
+
+function findCircleNum(isConnected) {
+ const n = isConnected.length;
+ let cnt = 0;
+ const vis = new Array(n + 1).fill(0);
+ const adj = Array.from({ length: n + 1 }, () => []);
+
+ // Build adjacency list
+ for (let i = 0; i < n; i++) {
+ for (let j = 0; j < n; j++) {
+ if (i !== j && isConnected[i][j] === 1) {
+ adj[i + 1].push(j + 1);
+ }
+ }
+ }
+
+ // Find all provinces
+ for (let i = 1; i <= n; i++) {
+ if (vis[i] === 0) {
+ cnt++;
+ dfs(i, vis, adj);
+ }
+ }
+
+ return cnt;
+}
+
+
+const input = [[1,1,0],[1,1,0],[0,0,1]]
+const output = findCircleNum(input);
+ return (
+
+
+ Input: {JSON.stringify(input)}
+
+
+ Output: {output.toString()}
+
+
+ );
+}
+```
+
+### Code in Different Languages
+
+
+
+
+ ```javascript
+ function dfs(root, vis, adj) {
+ vis[root] = 1;
+ for (let val of adj[root]) {
+ if (vis[val] === 0) {
+ dfs(val, vis, adj);
+ }
+ }
+}
+
+function findCircleNum(isConnected) {
+ const n = isConnected.length;
+ let cnt = 0;
+ const vis = new Array(n + 1).fill(0);
+ const adj = Array.from({ length: n + 1 }, () => []);
+
+ // Build adjacency list
+ for (let i = 0; i < n; i++) {
+ for (let j = 0; j < n; j++) {
+ if (i !== j && isConnected[i][j] === 1) {
+ adj[i + 1].push(j + 1);
+ }
+ }
+ }
+
+ // Find all provinces
+ for (let i = 1; i <= n; i++) {
+ if (vis[i] === 0) {
+ cnt++;
+ dfs(i, vis, adj);
+ }
+ }
+
+ return cnt;
+}
+
+```
+
+
+
+ ```typescript
+class Solution {
+ dfs(root: number, vis: number[], adj: number[][]): void {
+ vis[root] = 1;
+ for (let val of adj[root]) {
+ if (vis[val] === 0) {
+ this.dfs(val, vis, adj);
+ }
+ }
+ }
+
+ findCircleNum(isConnected: number[][]): number {
+ const n = isConnected.length;
+ let cnt = 0;
+ const vis = new Array(n + 1).fill(0);
+ const adj: number[][] = Array.from({ length: n + 1 }, () => []);
+
+ // Build adjacency list
+ for (let i = 0; i < n; i++) {
+ for (let j = 0; j < n; j++) {
+ if (i !== j && isConnected[i][j] === 1) {
+ adj[i + 1].push(j + 1);
+ }
+ }
+ }
+
+ // Find all provinces
+ for (let i = 1; i <= n; i++) {
+ if (vis[i] === 0) {
+ cnt++;
+ this.dfs(i, vis, adj);
+ }
+ }
+
+ return cnt;
+ }
+}
+
+ ```
+
+
+
+ ```python
+ class Solution:
+ def dfs(self, root, vis, adj):
+ vis[root] = 1
+ for val in adj[root]:
+ if not vis[val]:
+ self.dfs(val, vis, adj)
+
+ def findCircleNum(self, isConnected):
+ n = len(isConnected)
+ cnt = 0
+ vis = [0] * (n + 1)
+ adj = [[] for _ in range(n + 1)]
+
+ # Build adjacency list
+ for i in range(n):
+ for j in range(n):
+ if i != j and isConnected[i][j] == 1:
+ adj[i + 1].append(j + 1)
+
+ # Find all provinces
+ for i in range(1, n + 1):
+ if not vis[i]:
+ cnt += 1
+ self.dfs(i, vis, adj)
+
+ return cnt
+ ```
+
+
+
+```java
+import java.util.*;
+
+class Solution {
+ public void dfs(int root, int[] vis, List[] adj) {
+ vis[root] = 1;
+ for (int val : adj[root]) {
+ if (vis[val] == 0) {
+ dfs(val, vis, adj);
+ }
+ }
+ }
+
+ public int findCircleNum(int[][] isConnected) {
+ int n = isConnected.length;
+ int cnt = 0;
+ int[] vis = new int[n + 1];
+ List[] adj = new ArrayList[n + 1];
+
+ for (int i = 0; i <= n; i++) {
+ adj[i] = new ArrayList<>();
+ }
+
+ // Build adjacency list
+ for (int i = 0; i < n; i++) {
+ for (int j = 0; j < n; j++) {
+ if (i != j && isConnected[i][j] == 1) {
+ adj[i + 1].add(j + 1);
+ }
+ }
+ }
+
+ // Find all provinces
+ for (int i = 1; i <= n; i++) {
+ if (vis[i] == 0) {
+ cnt++;
+ dfs(i, vis, adj);
+ }
+ }
+
+ return cnt;
+ }
+}
+
+```
+
+
+
+```cpp
+class Solution {
+public:
+ void dfs(int root, vector& vis, vector adj[]){
+
+ vis[root]=1;
+ for (auto val : adj[root]){
+ if(!vis[val]){
+ dfs(val,vis,adj);
+ }
+ }
+ }
+
+ int findCircleNum(vector>& isConnected) {
+
+ int n= isConnected.size();
+ int cnt=0;
+ vector vis(n+1,0);
+ vector adj[n+1];
+ for (int i=0; i
+
+
+#### Complexity Analysis
+ ##### Time Complexity:
+ - The time complexity of the algorithm is $O(N^2)$, where N is the number of vertices (or cities) in the graph. This complexity arises because the algorithm involves visiting every vertex once and, for each vertex, iterating through all possible adjacent vertices to explore the edges. In the worst-case scenario, this results in checking every entry in the isConnected matrix once, which has $(N^2)$ entries.
+
+- The dfs function explores all connected vertices through recursive calls. Since each edge and vertex will only be visited once in the DFS traversal, the total number of operations performed will be related to the total number of vertices and edges. However, because the graph is represented by an N x N adjacency matrix and it must be fully inspected to discover all connections, the time is bounded by the size of the matrix $(N^2)$.
+
+ ##### Space Complexity:
+ The space complexity of the algorithm is $O(N)$, which comes from the following:
+- The recursion stack for DFS, which in the worst case, could store up to N frames if the graph is implemented as a linked structure such as a list of nodes (a path with all nodes connected end-to-end).
+- The vis visited array, which is a boolean array of length N used to track whether each vertex has been visited or not to prevent cycles during the DFS.
+- Given that N recursion calls could happen in a singly connected component spanning all the vertices, the space taken by the call stack should be considered in the final space complexity, merging it with the space taken by the array to $O(N)$.
+
+
+
+
+## References
+
+- **LeetCode Problem**: [Number of Provinces](https://leetcode.com/problems/number-of-provinces/description/)
+
+- **Solution Link**: [LeetCode Solution](https://leetcode.com/problems/number-of-provinces/solutions)
+
diff --git a/dsa/Algorithms/Tree/level-order-traversal.md b/dsa/Algorithms/Tree/level-order-traversal.md
new file mode 100644
index 000000000..98d083fc3
--- /dev/null
+++ b/dsa/Algorithms/Tree/level-order-traversal.md
@@ -0,0 +1,321 @@
+---
+id: level-order-traversal
+title: Level Order Traversal
+sidebar_label: Level Order Traversal
+tags:
+- Tree
+- Breadth-First Search
+- Binary Tree
+description: "This is a solution to the Binary Tree Level Order Traversal problem on LeetCode."
+---
+
+## Problem Description
+Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level).
+
+### Examples
+
+**Example 1:**
+
+```
+Input: root = [3,9,20,null,null,15,7]
+Output: [[3],[9,20],[15,7]]
+```
+
+**Example 2:**
+```
+Input: root = [1]
+Output: [[1]]
+```
+
+
+### Constraints
+- The number of nodes in the tree is in the range [0, 2000].
+- `-1000 <= Node.val <= 1000`
+
+## Solution for Binary Tree Level Order Traversal
+
+### Intuition
+- To perform a level-order traversal on a binary tree and store the nodes’ values in a 2D vector representing each level, start by initialising an empty queue to hold the level by level nodes.Enqueue the root node into the queue and traverse until the queue is empty. For each level, track the number of nodes in that level, creating a temporary vector to deque and store them. At each node, store its value in the temporary vector and enqueue its left and right children if they exist.Once all the nodes at a level are processed add this 1D temporary vector to the final 2D vector, representing that level. This process repeats until all levels are traversed. Finally, return this 2D vector containing the level order traversal of the binary tree.
+
+
+#### Implementation
+
+```jsx live
+function Solution() {
+function TreeNode(val = 0, left = null, right = null) {
+ this.val = val;
+ this.left = left;
+ this.right = right;
+}
+function constructTreeFromArray(array) {
+ if (!array.length) return null;
+
+ let root = new TreeNode(array[0]);
+ let queue = [root];
+ let i = 1;
+
+ while (i < array.length) {
+ let currentNode = queue.shift();
+
+ if (array[i] !== null) {
+ currentNode.left = new TreeNode(array[i]);
+ queue.push(currentNode.left);
+ }
+ i++;
+
+ if (i < array.length && array[i] !== null) {
+ currentNode.right = new TreeNode(array[i]);
+ queue.push(currentNode.right);
+ }
+ i++;
+ }
+ return root;
+}
+function levelOrder(root) {
+ if (!root) return [];
+
+ const queue = [root];
+ const ans = [];
+
+ while (queue.length > 0) {
+ const size = queue.length;
+ const temp = [];
+
+ for (let i = 0; i < size; i++) {
+ const curr = queue.shift();
+
+ if (curr.left) queue.push(curr.left);
+ if (curr.right) queue.push(curr.right);
+
+ temp.push(curr.val);
+ }
+
+ ans.push(temp);
+ }
+
+ return ans;
+}
+
+
+const array = [3,9,20,null,null,15,7]
+const input = constructTreeFromArray(array)
+const output = levelOrder(input)
+ return (
+
+
+ Input: {JSON.stringify(array)}
+
+
+ Output: {output.toString()}
+
+
+ );
+}
+```
+
+### Code in Different Languages
+
+
+
+
+ ```javascript
+ }
+function levelOrder(root) {
+ if (!root) return [];
+
+ const queue = [root];
+ const ans = [];
+
+ while (queue.length > 0) {
+ const size = queue.length;
+ const temp = [];
+
+ for (let i = 0; i < size; i++) {
+ const curr = queue.shift();
+
+ if (curr.left) queue.push(curr.left);
+ if (curr.right) queue.push(curr.right);
+
+ temp.push(curr.val);
+ }
+
+ ans.push(temp);
+ }
+
+ return ans;
+}
+```
+
+
+
+ ```typescript
+ class TreeNode {
+ val: number;
+ left: TreeNode | null;
+ right: TreeNode | null;
+ constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) {
+ this.val = (val === undefined ? 0 : val);
+ this.left = (left === undefined ? null : left);
+ this.right = (right === undefined ? null : right);
+ }
+}
+
+function levelOrder(root: TreeNode | null): number[][] {
+ if (!root) return [];
+
+ const queue: TreeNode[] = [root];
+ const ans: number[][] = [];
+
+ while (queue.length > 0) {
+ const size = queue.length;
+ const temp: number[] = [];
+
+ for (let i = 0; i < size; i++) {
+ const curr = queue.shift()!;
+
+ if (curr.left) queue.push(curr.left);
+ if (curr.right) queue.push(curr.right);
+
+ temp.push(curr.val);
+ }
+
+ ans.push(temp);
+ }
+
+ return ans;
+}
+ ```
+
+
+
+ ```python
+from collections import deque
+class TreeNode:
+ def __init__(self, val=0, left=None, right=None):
+ self.val = val
+ self.left = left
+ self.right = right
+
+class Solution:
+ def levelOrder(self, root: TreeNode) -> List[List[int]]:
+ if not root:
+ return []
+
+ q = deque([root])
+ ans = []
+
+ while q:
+ size = len(q)
+ temp = []
+
+ for _ in range(size):
+ curr = q.popleft()
+
+ if curr.left:
+ q.append(curr.left)
+ if curr.right:
+ q.append(curr.right)
+
+ temp.append(curr.val)
+
+ ans.append(temp)
+
+ return ans
+ ```
+
+
+
+```java
+import java.util.*;
+
+class TreeNode {
+ int val;
+ TreeNode left;
+ TreeNode right;
+ TreeNode(int x) { val = x; }
+}
+
+class Solution {
+ public List> levelOrder(TreeNode root) {
+ Queue q = new LinkedList<>();
+ List> ans = new ArrayList<>();
+
+ if (root == null) return ans;
+
+ q.offer(root);
+
+ while (!q.isEmpty()) {
+ int size = q.size();
+ List temp = new ArrayList<>();
+
+ for (int i = 0; i < size; i++) {
+ TreeNode curr = q.poll();
+
+ if (curr.left != null) q.offer(curr.left);
+ if (curr.right != null) q.offer(curr.right);
+
+ temp.add(curr.val);
+ }
+
+ ans.add(temp);
+ }
+
+ return ans;
+ }
+}
+
+```
+
+
+
+```cpp
+class Solution {
+public:
+ vector> levelOrder(TreeNode* root) {
+ queue q;
+ vector> ans;
+
+ if(!root) return ans;
+
+ q.push(root);
+
+ while(!q.empty()){
+ int size = q.size();
+ vector temp;
+
+ while(size--){
+ TreeNode *curr = q.front();
+ q.pop();
+
+ if(curr->left) q.push(curr->left);
+ if(curr->right) q.push(curr->right);
+
+ temp.push_back(curr->val);
+ }
+
+ ans.push_back(temp);
+ }
+
+ return ans;
+ }
+};
+```
+
+
+
+#### Complexity Analysis
+ ##### Time Complexity:
+ - $O(N)$ where N is the number of nodes in the binary tree. Each node of the binary tree is enqueued and dequeued exactly once, hence all nodes need to be processed and visited. Processing each node takes constant time operations which contributes to the overall linear time complexity.
+
+ ##### Space Complexity:
+ - $O(N)$ where N is the number of nodes in the binary tree. In the worst case, the queue has to hold all the nodes of the last level of the binary tree, the last level could at most hold N/2 nodes hence the space complexity of the queue is proportional to $O(N)$.The resultant vector answer also stores the values of the nodes level by level and hence contains all the nodes of the tree contributing to O(N) space as well.
+
+
+
+
+## References
+
+- **LeetCode Problem**: [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/)
+
+- **Solution Link**: [LeetCode Solution](hhttps://leetcode.com/problems/binary-tree-level-order-traversal/solutions)
+