Interview Question

Automation Test Engineer Interview

-Hyderābād

Oracle

Code to find a missing number in an array

AnswerAdd Tags

Interview Answers

5 Answers

0

public void missing() { ArrayList arr = new ArrayList(); int a[] = { 1, 3, 4, 5, 6, 7, 10 }; int j = a[0]; for (int i = 0; i < a.length; i++) { if (j == a[i]) { j++; continue; } else { arr.add(j); i--; j++; } } System.out.println("missing numbers are "); for (int r : arr) { System.out.println(" " + r); } }

Samit Bhunia on

0

Does the numbes in an array lies in between a specific range ?

Shabana Khan on

0

Does the numbes in an array lies in between a specific range ?

Shabana Khan on

0

Does the numbes in an array lies in between a specific range ?

Shabana Khan on

0

public static int findMissingNumber(int[] a) { int n=a.length; int expectedNumber=n*(n+1)/2; int actualsum=0; for(int i=0;i

Shabana Khan on

Add Answers or Comments

To comment on this, Sign In or Sign Up.