Skip to content

Commit 9f7b1b9

Browse files
committed
updated as per your suggestion
1 parent 6639631 commit 9f7b1b9

10 files changed

+40
-41
lines changed

dsa-solutions/gfg-solutions/Easy problems/bfs-of-graph.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ Starting from 0, it will go to 1 then 2, thus BFS will be 0 1 2.
4444

4545
You don't need to read input or print anything. Your task is to complete the function `bfsOfGraph()` which takes the integer `V` denoting the number of vertices and adjacency list as input parameters and returns a list containing the BFS traversal of the graph starting from the 0th vertex from left to right.
4646

47-
**Expected Time Complexity:** $ O(V + E) $
47+
**Expected Time Complexity:** $O(V + E)$
4848
**Expected Auxiliary Space:** $O(V)$
4949

5050
**Constraints**
51-
- $ 1 ≤ V, E ≤ 10^4 $
51+
- $1 ≤ V, E ≤ 10^4$
5252

5353
## Solution
5454

@@ -211,10 +211,10 @@ class Solution {
211211

212212
## Complexity analysis
213213

214-
The provided solutions efficiently perform a Breadth First Search (BFS) traversal of a directed graph. By starting from the 0th vertex and using a queue to manage the traversal, the algorithms ensure that all reachable vertices are visited in the correct order. The solutions operate in O(V + E) time and use O(V) space complexity, where V and E are the numbers of vertices and edges in the graph, respectively.
214+
The provided solutions efficiently perform a Breadth First Search (BFS) traversal of a directed graph. By starting from the 0th vertex and using a queue to manage the traversal, the algorithms ensure that all reachable vertices are visited in the correct order. The solutions operate in $O(V + E)$ time and use $O(V)$ space complexity, where V and E are the numbers of vertices and edges in the graph, respectively.
215215

216-
**Time Complexity:** $ O(V + E) $
217-
**Auxiliary Space:** $ O(V)$
216+
**Time Complexity:** $O(V + E)$
217+
**Auxiliary Space:** $O(V)$
218218

219219
## References
220220

dsa-solutions/gfg-solutions/Easy problems/check-for-balanced-tree.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Output: true
5050
### Constraints
5151

5252
- The number of nodes in the tree is in the range `[0, 5000]`.
53-
- $ -10^4 <=$ Node.val $<= 10^4 $
53+
- $-10^4 <=$ Node.val $<= 10^4$
5454

5555
---
5656

dsa-solutions/gfg-solutions/Easy problems/delete-middle-of-linked-list.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ Output:
4141
### Your Task
4242
The task is to complete the function `deleteMid()` which takes head of the linked list and returns head of the linked list with the middle element deleted. If the linked list is empty or contains a single element, then it should return NULL.
4343

44-
**Expected Time Complexity:** O(n).
45-
**Expected Auxiliary Space:** O(1).
44+
**Expected Time Complexity:** $O(n)$
45+
**Expected Auxiliary Space:** $O(1)$
4646

4747
### Constraints
48-
1 ≤ n ≤ 10^5
49-
1 ≤ value[i] ≤ 10^9
48+
- $1 ≤ n ≤ 10^5$
49+
- $1 ≤ value[i] ≤ 10^9$
5050

5151
## Solution
5252

@@ -59,8 +59,7 @@ To delete the middle node, ensure that the `slow` pointer is at the node just be
5959
**Edge Case:** If there is only one node in the linked list, return NULL or None.
6060

6161
### Complexity
62-
- **Time Complexity:** O(n)
63-
- **Space Complexity:** O(1)
62+
- **Time Complexity:** $O(n)$- **Space Complexity:** O(1)
6463

6564
### Implementation
6665

@@ -164,8 +163,8 @@ function deleteMid(head: ListNode | null): ListNode | null {
164163
</Tabs>
165164

166165
### Complexity
167-
- **Time Complexity:** O(n)
168-
- **Space Complexity:** O(1)
166+
- **Time Complexity:** $O(n)$
167+
- **Space Complexity:** $O(1)$
169168

170169
---
171170

dsa-solutions/gfg-solutions/Easy problems/delete-without-head-pointer.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ we have remaining nodes as 10, 4, 30.
5858
### Your Task
5959
You don't need to read or print anything. You only need to complete the function `deleteNode()` which takes a reference of the deleting node value and your task is to delete the given node value.
6060

61-
**Expected Time Complexity:** O(1)
62-
**Expected Auxiliary Space:** O(1)
61+
**Expected Time Complexity:** $O(1)$
62+
**Expected Auxiliary Space:** $O(1)$
6363

6464
### Constraints
65-
2 ≤ n ≤ 10^3
66-
1 ≤ elements of the linked list ≤ 10^9
65+
- $2 ≤ n ≤ 10^3$
66+
- $1 ≤ elements of the linked list ≤ 10^9$
6767

6868
## Solution
6969

@@ -213,8 +213,8 @@ class Solution {
213213

214214
### Complexity Analysis
215215

216-
- **Time Complexity:** O(1), as the deletion operation requires constant time regardless of the size of the linked list.
217-
- **Space Complexity:** O(1), as the algorithm uses only a constant amount of extra space regardless of the input size.
216+
- **Time Complexity:** $O(1)$, as the deletion operation requires constant time regardless of the size of the linked list.
217+
- **Space Complexity:** $O(1)$, as the algorithm uses only a constant amount of extra space regardless of the input size.
218218

219219
---
220220

dsa-solutions/gfg-solutions/Easy problems/dfs-of-graph.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ Thus DFS will be 0 1 2 3.
5252

5353
You don't need to read input or print anything. Your task is to complete the function `dfsOfGraph()` which takes the integer `V` denoting the number of vertices and adjacency list as input parameters and returns a list containing the DFS traversal of the graph starting from the 0th vertex from left to right according to the graph.
5454

55-
- **Expected Time Complexity:** $ O(V + E) $
56-
- **Expected Auxiliary Space:** $ O(V)$
55+
- **Expected Time Complexity:** $O(V + E)$
56+
- **Expected Auxiliary Space:** $O(V)$
5757

5858
**Constraints**
5959
- $ 1 ≤ V, E ≤ 10^4 $

dsa-solutions/gfg-solutions/Easy problems/implement-two-stacks-in-an-array.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ class TwoStacks {
337337

338338
## Complexity Analysis
339339

340-
The provided solutions efficiently implement two stacks in a single array using pointers. This approach ensures a time complexity of O(1) for all stack operations and an auxiliary space complexity of O(1). The algorithms are designed to handle up to 10^4 queries efficiently without relying on dynamic data structures.
340+
The provided solutions efficiently implement two stacks in a single array using pointers. This approach ensures a time complexity of $O(1)$ for all stack operations and an auxiliary space complexity of $O(1)$. The algorithms are designed to handle up to $10^4$ queries efficiently without relying on dynamic data structures.
341341

342342
**Time Complexity:** $O(1)$ for all the four methods.
343343
**Auxiliary Space:** $O(1)$ for all the four methods.

dsa-solutions/gfg-solutions/Easy problems/intersection-of-two-sorted-linked-lists.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ Output:
4545

4646
You don't have to take any input or print anything. Your task is to complete the function `findIntersection()`, which will take the head of both of the linked lists as input and should find the intersection of the two linked lists and add all the elements in the intersection to the third linked list and return the head of the third linked list.
4747

48-
**Expected Time Complexity:** O(n + m)
49-
**Expected Auxiliary Space:** O(n + m)
48+
**Expected Time Complexity:** $O(n + m)$
49+
**Expected Auxiliary Space:** $O(n + m)$
5050

5151
**Note:** n, m are the sizes of the respective linked lists.
5252

5353
### Constraints
54-
1 ≤ size of linked lists ≤ 5000
55-
1 ≤ Data in linked list nodes ≤ 10^4
54+
- $1 ≤ size of linked lists ≤ 5000$
55+
- $1 ≤ Data in linked list nodes ≤ 10^4$
5656

5757
## Solution
5858

@@ -231,8 +231,8 @@ class Solution {
231231
</TabItem>
232232
</Tabs>
233233

234-
**Time Complexity:** O(n + m)
235-
**Auxiliary Space:** O(n + m)
234+
**Time Complexity:** $O(n + m)$
235+
**Auxiliary Space:** $O(n + m)$
236236

237237
## References
238238

dsa-solutions/gfg-solutions/Easy problems/reverse-a-doubly-linked-list.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ After reversing the list, elements are 196 <--> 59 <--> 122 <--> 75.
4545
### Your Task
4646
Your task is to complete the given function `reverseDLL()`, which takes head reference as an argument and reverses the elements in-place such that the tail becomes the new head and all pointers are pointing in the right order. You need to return the new head of the reversed list.
4747

48-
**Expected Time Complexity:** $ O(N)$
48+
**Expected Time Complexity:** $O(N)$
4949
**Expected Auxiliary Space:** $O(1)$
5050

5151
### Constraints
52-
- $ 1 ≤ number of nodes ≤ 10^4 $
53-
- $ 0 ≤ value of nodes ≤ 10^4 $
52+
- $1 ≤ number of nodes ≤ 10^4$
53+
- $0 ≤ value of nodes ≤ 10^4$
5454

5555
## Solution
5656

@@ -155,7 +155,7 @@ class Solution {
155155

156156
### Complexity Analysis
157157

158-
- **Time Complexity:** $ O(N),$ where N is the number of elements in the doubly linked list. We traverse the entire list once.
158+
- **Time Complexity:** $O(N),$ where N is the number of elements in the doubly linked list. We traverse the entire list once.
159159
- **Space Complexity:** $O(1)$, as we only use a constant amount of extra space for pointers.
160160

161161
---

dsa-solutions/gfg-solutions/Easy problems/reverse-a-linked-list.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ function reverseList(head: ListNode | null): ListNode | null {
178178

179179
### Complexity Analysis
180180

181-
- **Time Complexity:** $ O(N) $, where N is the number of nodes in the linked list. We traverse the entire list once.
182-
- **Space Complexity:** $ O(1) $, as we only use a constant amount of extra space for pointers.
181+
- **Time Complexity:** $O(N)$, where N is the number of nodes in the linked list. We traverse the entire list once.
182+
- **Space Complexity:** $O(1)$, as we only use a constant amount of extra space for pointers.
183183

184184
---
185185

dsa-solutions/gfg-solutions/Easy problems/square-root.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ Explanation: Since 4 is a perfect square, its square root is 2.
3939

4040
You don't need to read input or print anything. The task is to complete the function `floorSqrt()` which takes `x` as the input parameter and returns its square root. Note: Try solving the question without using the sqrt function. The value of `x` ≥ 0.
4141

42-
**Expected Time Complexity:** $ O(log N) $
43-
**Expected Auxiliary Space:** $ O(1) $
42+
**Expected Time Complexity:** $O(log N)$
43+
**Expected Auxiliary Space:** $O(1)$
4444

4545
**Constraints**
46-
- $ 1 ≤ x ≤ 10^7 $
46+
- $1 ≤ x ≤ 10^7$
4747

4848
## Solution
4949

@@ -187,10 +187,10 @@ class Solution {
187187

188188
## Complexity Analysis
189189

190-
The provided solutions efficiently find the floor value of the square root of a given integer `x` using binary search. This approach ensures a time complexity of $ O(log N) and an auxiliary space complexity of $ O(1) $. The algorithms are designed to handle large values of `x` up to 10^7 efficiently without relying on built-in square root functions.
190+
The provided solutions efficiently find the floor value of the square root of a given integer `x` using binary search. This approach ensures a time complexity of $ O(log N) and an auxiliary space complexity of $O(1)$. The algorithms are designed to handle large values of `x` up to 10^7 efficiently without relying on built-in square root functions.
191191

192-
**Time Complexity:** $ O(log N) $
193-
**Auxiliary Space:** $ O(1) $
192+
**Time Complexity:** $O(log N)$
193+
**Auxiliary Space:** $O(1)$
194194

195195
---
196196

0 commit comments

Comments
 (0)