(int arr[], int n)
| 1 | class Solve |
| 2 | { |
| 3 | int[] findTwoElement(int arr[], int n) |
| 4 | { |
| 5 | // code here |
| 6 | int result[] = new int[2]; |
| 7 | |
| 8 | int sum=0; |
| 9 | |
| 10 | int origSum=0; |
| 11 | |
| 12 | for(int i=0;i<n;i++) |
| 13 | { |
| 14 | int index = Math.abs(arr[i])-1; |
| 15 | |
| 16 | if(arr[index]<0) |
| 17 | { |
| 18 | result[0] = Math.abs(arr[i]); |
| 19 | } |
| 20 | |
| 21 | arr[index] = -arr[index]; |
| 22 | |
| 23 | sum+=Math.abs(arr[i]); |
| 24 | |
| 25 | origSum+=(i+1); |
| 26 | } |
| 27 | result[1]=origSum-(sum-result[0]); |
| 28 | |
| 29 | return result; |
| 30 | } |
| 31 | } |
nothing calls this directly
no outgoing calls
no test coverage detected