Expedia Interview Question for Software Engineer / Developers






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

say arr = {1, 2, 2, 3, 4, 4, 4, 5}
we need to change it into
arr - {1, 2, 3, 4, 5}

int num = arr[0];
list.add(num);
int j = 0;
for( int i = 1; i < arr.length; i++ ) {
if( list.get(j) < arr[i] ) {
list.add(arr[i]);
j++;
}
else { // duplicate
continue;
}
}

This solves the problem with complexity O(n), but requires an extra list.

- Jimmy December 10, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void foo(char *str)
{
char *dest=str;

while(*str)
{
if ( *str != *(str+1) )
*dest++ = *str;

str++;
}
*dest = '\0';
}

- snowgoose May 12, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

can solve this with the same list by using 2 index variables 1 for reading current element & progressing forward(readPos) & the other for write position. Every time before writing something at write pos, compare it with readPos

- ST May 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can u post ur code please

- Anonymous February 18, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

My 2 cents...

public static void removeDuplicates(int[] a1) {
int a2[] = new int[6];
int j = 0;
for (int i = 0; i < a1.length; i++) {
if (i < (a1.length - 1)) {
if (a1[i] == a1[i + 1]) {
} else {
a2[j] = a1[i];
j++;
}
} else {
if (a1[i] == a1[i - 1]) {
a2[j] = a1[i];
} else {
a2[j] = a1[i];
}
}
}
for (int i = 0; i < a2.length; i++) {
System.out.println(a2[i]);
}
}

- Barani February 28, 2012 | 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