Skip to content

Commit a7c04fb

Browse files
committed
changes
1 parent c6f389e commit a7c04fb

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

dsa-solutions/gfg-solutions/0001-value-equal-to-index-value.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ description: "This is a solution to the Value Equal to Index Value problem on Ge
1515

1616
## Problem Description
1717

18-
Given an array Arr of N positive integers. Your task is to find the elements whose value is equal to that of its index value ( Consider 1-based indexing ).<br />
18+
Given an array Arr of N positive integers. Your task is to find the elements whose value is equal to that of its index value (Consider 1-based indexing).
1919

2020
Note: There can be more than one element in the array which have the same value as its index. You need to include every such element's index. Follows 1-based indexing of the array.
2121

@@ -52,16 +52,16 @@ You don't need to read input or print anything. Your task is to complete the fun
5252

5353
## Problem Explanation
5454

55-
The problem involves finding elements in an array whose values match their index positions, considering 1-based indexing. This means if an element's value matches its position in the array when counting from 1 (not 0), it should be included in the result.<br />
55+
The problem involves finding elements in an array whose values match their index positions, considering 1-based indexing. This means if an element's value matches its position in the array when counting from 1 (not 0), it should be included in the result.
5656

5757
Example:
5858

5959
* Given an array [15, 2, 45, 12, 7]:
60-
- At 0-based index 0, the value is 15 (not equal to 1)
61-
- At 0-based index 1, the value is 2 (equal to 2)
62-
- At 0-based index 2, the value is 45 (not equal to 3)
63-
- At 0-based index 3, the value is 12 (not equal to 4)
64-
- At 0-based index 4, the value is 7 (not equal to 5)
60+
- At 1-based index 1, the value is 15 (not equal to 1)
61+
- At 1-based index 2, the value is 2 (equal to 2)
62+
- At 1-based index 3, the value is 45 (not equal to 3)
63+
- At 1-based index 4, the value is 12 (not equal to 4)
64+
- At 1-based index 5, the value is 7 (not equal to 5)
6565

6666
The only element that matches its index is 2 at index 2.
6767

@@ -108,17 +108,17 @@ For the array `[15, 2, 45, 12, 7]` with length `n = 5`:
108108
* Initialize an empty list: `result = []`
109109
* Loop through the array with indices from 0 to 4:
110110
- Check element at index 0 (1-based index 1): 15 ≠ 1
111-
Check element at index 1 (1-based index 2): 2 = 2 (add to result)
112-
Check element at index 2 (1-based index 3): 45 ≠ 3
113-
Check element at index 3 (1-based index 4): 12 ≠ 4
114-
Check element at index 4 (1-based index 5): 7 ≠ 5
111+
- Check element at index 1 (1-based index 2): 2 = 2 (add to result)
112+
- Check element at index 2 (1-based index 3): 45 ≠ 3
113+
- Check element at index 3 (1-based index 4): 12 ≠ 4
114+
- Check element at index 4 (1-based index 5): 7 ≠ 5
115115
116116
Final `result` list: `[2]`
117117
118118
## Time Complexity
119119
120-
The time complexity of this solution is O(N) where N is the number of elements in the array. This is because the solution involves a single pass through the array to check each element against its 1-based index.
120+
The time complexity of this solution is $O(N)$ where N is the number of elements in the array. This is because the solution involves a single pass through the array to check each element against its 1-based index.
121121
122122
## Space Complexity
123123
124-
The space complexity is O(1) for the input space, and O(K) for the output space, where K is the number of elements matching the condition. In the worst case, if all elements match, the space used by the result list will be O(N).
124+
The space complexity is $O(1)$ for the input space, and $O(K)$ for the output space, where K is the number of elements matching the condition. In the worst case, if all elements match, the space used by the result list will be $O(N)$.

dsa-solutions/gfg-solutions/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"label": "LeetCode Solutions",
2+
"label": "GFG Solutions",
33
"position": 4,
44
"link": {
55
"type": "generated-index",

0 commit comments

Comments
 (0)