Adobe Interview Question for Software Engineer / Developers






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

how come 1 is a multiple of 2 or 5?
Assuming the begining 1 is by mistake, next number in sequence is 20 ?

- Anonymous March 11, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

2^0 = 5^0 = 1

- Anonymous March 11, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

If previous term of sequence is even:
let it be x
next multiple of 2=2^(x+1)

power of 5 till now: log(x)/log(5)

next multiple of 5 = 5^(power of 5 till now+1)

find which 1 is small.

Do the converse for previous term is multiple of 5..:)

- y so serious May 10, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

1 is not a multiple of 3 but a factor of 3. A multiple is anything that is gotten by multiplying a given number(3 or 5 in this case) with 1,2,3,...

- Anonymous March 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

x = last no in the sequence

if (x+1)%5==0
  return x+1
else return x+2

- Anonymous March 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

x = last no in the sequence


if (x+1)%5==0
  return x+1
else return x+2

- bindasarpan March 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

The successor to 10 should be 16, not 12.

- Anonymous March 12, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

printing the next 100..

public static void main(String[] args){
int[] ar={1,2,4,5,10,16,20};
LinkedList<Integer> list = new LinkedList();
for(int i:ar){
list.add(i);
}

for(int j=0;j<100;j++){
int next = list.getLast()*2;
for(int i=6;i>=0;i--){
if(next>list.get(i)*2 && list.get(i)*2>list.getLast())
next=list.get(i)*2;
if(next>list.get(i)*5 && list.get(i)*5>list.getLast())
next = list.get(i)*5;

}
System.out.println(next);
list.remove(0);
list.add(next);
}
}

- Nitesh March 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

some mistake above..
modified code

public class seq {
public static void main(String[] args){
int[] ar={1,2,4};
LinkedList<Integer> list = new LinkedList();
for(int i:ar){
list.add(i);
}

for(int j=0;j<50;j++){
int next = list.getLast()*2;
for(int i=ar.length-1;i>=0;i--){
if(next>list.get(i)*2 && list.get(i)*2>list.getLast())
next=list.get(i)*2;
if(next>list.get(i)*5 && list.get(i)*5>list.getLast())
next = list.get(i)*5;

}
System.out.println(next);
list.remove(0);
list.add(next);
}
}
}

- Nitesh March 12, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice logic!

- novice May 11, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

public class seq {
public static void main(String[] args){
int[] ar={1,2,4};
LinkedList<Integer> list = new LinkedList();
for(int i:ar){
	list.add(i);
	}

for(int j=0;j<50;j++){
	int next = list.getLast()*2;
	int prevNext = 0;
	for(int i=ar.length-1;i>=0;i--) {

		// Checking for 5 first gives the lower next value
		if(list.get(i)*5 > list.getLast())
			next = list.get(i)*5;

		if(list.get(i)*2>list.getLast())
			next=list.get(i)*2;
	
		// Get the smaller out of previous next and newer next
		if (prevNext > next) {
			prevNext = next;
		}
	}
	System.out.println(next);
	list.remove(0);
	list.add(next);
}
	}
}

- Anon April 18, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class seq {
public static void main(String[] args){
int[] ar={1,2,4};
LinkedList<Integer> list = new LinkedList();
for(int i:ar){
list.add(i);
}

for(int j=0;j<50;j++){
int next = list.getLast()*2;
for(int i=ar.length-1;i>=0;i--){
if(next>list.get(i)*2 && list.get(i)*2>list.getLast())
next=list.get(i)*2;
if(next>list.get(i)*5 && list.get(i)*5>list.getLast())
next = list.get(i)*5;

}
System.out.println(next);
list.remove(0);
list.add(next);
}
}
}

- abc March 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Your code is not working. E.g. you are missing 25.

- Anonymous March 12, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Actually this is called regular number (a slight variation of hamming number)
mathworld.wolfram.com/RegularNumber.html

code for printing first 100 numbers.

import java.util.*;

class Main {


	public static void main(String[] args) {
		List<Integer> first100 = getHammingNumbers(100);
		System.out.println("First 100 Hamming numbers: " + first100);
	}

	private static void updateFrontier(Integer value,
			Set<Integer> frontierSet) {
		frontierSet.add(value*2);
		frontierSet.add(value*5);
		return;
	}

	public static List<Integer> getHammingNumbers(int howMany) {
		List<Integer> completedNumbers = new ArrayList<Integer>();
		TreeSet<Integer> frontierSet = new TreeSet<Integer>();
		completedNumbers.add(1);
		updateFrontier(1, frontierSet);
		int count = 1;
		while (count < howMany) {
			Integer lowestNumber = frontierSet.pollFirst();
			completedNumbers.add(lowestNumber);
			count++;
			updateFrontier(lowestNumber, frontierSet);
		}
		return completedNumbers;
	}

}

- himas March 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

output:


First 100 Hamming numbers: [1, 2, 4, 5, 8, 10, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 128, 160, 200, 250, 256, 320, 400, 500, 512, 625, 640, 800, 1000, 1024, 1250, 1280, 1600, 2000, 2048, 2500, 2560, 3125, 3200, 4000, 4096, 5000, 5120, 6250, 6400, 8000, 8192, 10000, 10240, 12500, 12800, 15625, 16000, 16384, 20000, 20480, 25000, 25600, 31250, 32000, 32768, 40000, 40960, 50000, 51200, 62500, 64000, 65536, 78125, 80000, 81920, 100000, 102400, 125000, 128000, 131072, 156250, 160000, 163840, 200000, 204800, 250000, 256000, 262144, 312500, 320000, 327680, 390625, 400000, 409600, 500000, 512000, 524288, 625000, 640000, 655360, 781250, 800000, 819200, 1000000]

- himas March 16, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int next(int prev)
{
return ((prev%2) ? (prev+1):(prev%5):(prev+1):(prev+2));
}

- SachinGuptaMNNIT June 17, 2011 | 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