Oracle Interview Question: Code to find a missing number... | Glassdoor.co.in

Interview Question

Automation Test Engineer Interview Hyderabad

Code to find a missing number in an array

Answer

Interview Answer

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 11-Jul-2018
0

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

Shabana Khan on 09-May-2020
0

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

Shabana Khan on 09-May-2020
0

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

Shabana Khan on 09-May-2020
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 16-May-2020

Add Answers or Comments

To comment on this, Sign In or Sign Up.