MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / Solution

Class Solution

ValueEqualToIndexValue.java:1–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution {
2 ArrayList<Integer> valueEqualToIndex(int arr[], int n) {
3 // code here
4 ArrayList<Integer> list = new ArrayList<>();
5 for(int i=0;i<n;i++)
6 {
7 int val = arr[i];
8 int reqIn = i+1;
9 if(val == reqIn)
10 {
11 list.add(val);
12 }
13 }
14 return list;
15 }
16}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected