Adobe Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

Should the pair of equal elements be sequential? E.g. if the input is 4,4,0,4,8,0,0, should output be 8,4,8,0,0,0, or 16,4,0,0,0,0?

- Alex December 08, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package SimpleTools;
import java.util.Objects;

public class Sorting {
    
    public static int[] combineEqualPushZeros(int[] list){      
       
        System.out.print("You entered: { ");
        for (int i: list){System.out.print(i+" ");}
        System.out.println("}");
        
        for (int i = 0; i < list.length; i++){            
            if (list[i] != 0 ){                
                if (Objects.equals(list[i], list[i+1])){                    
                  list[i] = 2* list[i];
                  list[i+1] = 0;                  
                }        
            }
        }
        for (int i = 0 ; i < list.length-1;i++){        
            if (list[i] == 0 ){
                for (int j = i; j < list.length; j++){
                    if (list[j]>0){
                        downshift(list,i);
                        i--;
                    }
                }       
            }            
        } 
        System.out.print("You get:     { ");
        for (int i: list){System.out.print(i+" ");}
        System.out.println("}");        
        return list;
    }
    public static int[] downshift(int[] in, int shiftAt){
        
        int temp = in[shiftAt];        
        for (int i = shiftAt; i < in.length-1; i ++){
            in[i] = in[i+1];      
        }
        in[in.length-1]= temp;
        return in;
    }
}

- Smiller December 09, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class PairOfEqualElements {

private static String pairOfEqualElements(int[] num) {
String result="";
for(int i=0;i<num.length;i++) {
if(i<num.length-1) {
if(num[i]==num[i+1]&&num[i+1]!=0) {
result=result+num[i]*2;
num[i+1]=0;
}else if(num[i]!=num[i+1]&&num[i]!=0) {
result=result+num[i];
}
}
}for(int i=result.length();i<num.length;i++) {
result=result+0;
}
return result;
}

public static void main(String[] args) {
// TODO Auto-generated method stub
int num[]= {4,4,0,4,8,0,0};
String result=pairOfEqualElements(num);
System.out.println(result);
}
}

- shubham dwivedi February 14, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class PairOfEqualElements {

private static String pairOfEqualElements(int[] num) {
String result = "";
for (int i = 0; i < num.length; i++) {
if (i < num.length - 1) {
if (num[i] == num[i + 1] && num[i + 1] != 0) {
result = result + num[i] * 2;
num[i + 1] = 0;
} else if (num[i] != num[i + 1] && num[i] != 0) {
result = result + num[i];
}
}
}
for (int i = result.length(); i < num.length; i++) {
result = result + 0;
}
return result;
}

public static void main(String[] args) {
// TODO Auto-generated method stub
int num[] = { 4, 4, 0, 4, 8, 0, 0 };
String result = pairOfEqualElements(num);
System.out.println(result);

}

}

- shubham dwivedi February 14, 2018 | 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