Interview Question for Data Engineers


Country: United States




Comment hidden because of low score. Click to expand.
0
of 0 vote

int a[]={1,2,5,6,10,11,12,18,21,22,23,100};
int i=0;
int j=1;
while(j<=a[a.length-1]){
if(a[i]==j){
j++;
}else{
while(j<=a[i]){
if(a[i]==j){
j++;
break;
}
System.out.println(j);
j++;
}
}
i++;
}

- Anonymous October 04, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int a[]={1,2,5,6,10,11,12,18,21,22,23,100};
int i=0;
int j=1;
while(j<=a[a.length-1]){
if(a[i]==j){
j++;
}else{
while(j<=a[i]){
if(a[i]==j){
j++;
break;
}
System.out.println(j);
j++;
}
}
i++;
}

- sandeep U October 04, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{int a[]={1,2,5,6,10,11,12,18,21,22,23,100};
int i=0;
int j=1;
while(j<=a[a.length-1]){
if(a[i]==j){
j++;
}else{
while(j<=a[i]){
if(a[i]==j){
j++;
break;
}
System.out.println(j);
j++;
}
}
i++;
}}

- Anonymous October 04, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void FindGap(const std::vector<int>& data)
{
	assert(!data.empty());
	auto min = data.front();
	auto max = data.back();
	auto curIt = data.cbegin();
	bool first = true;
	
	for(auto i = min; i < max; i++)
		if(i != *curIt)
		{
			if(!first)
				std::cout << ',';
			std::cout << i;
			first = false;
		}
		else
			curIt++;
}

- dimansp October 04, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main (String[] args) {
	    int[] arr={1,2,5,7,11};
	    int len=arr.length;
	    int j=0;
	    for(int i=1;i<=arr[len-1];i++)
	    {
	        if(arr[j]==i)
	        j++;
	        
	        else
	        {
	           System.out.println(i);
	        }
	    }

- preethikrish75 October 05, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A correct solution for this during interview would depend on some clarifications:

* Is the input already sorted?
* If input is not sorted, do we want to optimize for time or space?
* what is exactly considered a gap? the sequence should start with 1 or with the minimum value already present?
* What about duplicates?

- Anonymous October 05, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What? Is that seriously MS Question ? No Way!!! ROFL

- hprem991 October 05, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>
#define SIZE 5
int main (void) {
	int a[SIZE] = {1,2,5,6,9};
	int i,p;
	for(i = a[0], p=0; i < a[SIZE-1]; i++) {
		if (a[p] == i) {p++; continue;}
		printf("%d ", i);
	}
	return 0;
}

- rbuyer October 07, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Does the comment work?

- rbuyer October 07, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class FindGap {

public static void main(String[] args) {
int a [] = {1, 2, 5, 6, 10};
printGap(a);

}

public static void printGap(int a[]) {
int max = maxElementOfArray(a);
int j = 0;
for (int i = 0; i < max; i++) {
if (a[j]==i) {
j++;
} else if(i > 0) {
System.out.print(i +", ");
}
}
}

public static int maxElementOfArray(int a[]) {
int max = Integer.MIN_VALUE;
for (int i : a) {
if (i > max) {
max = i;
}
}
return max;
}
}

- amitkannaujiyanitk September 12, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

test = [1,2,5,6,10,11,12,18,21,22,23,100]
test1 = []
for i in range(min(test),max(test)):
if i not in test:
test1.append(i)
print(test1)

- Vishal Dutt October 26, 2021 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

test = [1,2,5,6,10,11,12,18,21,22,23,100]
test1 = []
for i in range(min(test),max(test)):
    if i not in test:
        test1.append(i)
print(test1)

- Vishal Dutt October 26, 2021 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

private static void GetGap()
        {
            int[] vals = { 1, 2, 5, 6, 10 };
            var max = vals.Max();
            List<int> gaps = new List<int>();
            for (int i = 0; i < max; i++)
            {
                if (!vals.Contains(i) && i >  0 )
                    gaps.Add(i);

            }

            Console.WriteLine( string.Join("," ,gaps.Select(x=>x)));

        }

- MSal October 04, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

private static void GetGap()
        {
            int[] vals = { 1, 2, 5, 6, 10 };
            var max = vals.Max();
            List<int> gaps = new List<int>();
            for (int i = 0; i < max; i++)
            {
                if (!vals.Contains(i) && i >  0 )
                    gaps.Add(i);

            }

            Console.WriteLine( string.Join("," ,gaps.Select(x=>x)));

        }

- MSal October 04, 2017 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More