Adobe Interview Question for Interns


Country: India
Interview Type: Written Test




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

is it like each element must be rounded to the next power or the sum of all elements? I assume each element:

unsigned long long memory_required(const vector<unsigned int>& elements) {
	unsigned long long total = 0;
	for(auto e : elements) {
		unsigned long long mask = 1 << 31;
		while(mask > 0 && (mask & e) == 0) mask >>= 1;
		if(e == mask) total += mask;		
		else total += mask << 1;
	}
	return total;
}

- Chris November 29, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static int roundOff(int[] arr)
{
	int number = getSum(arr);
	
	return nextHighestPower(number);
}

private static int nextHighestPower(int number)
{
	if ((number & number - 1) == 0)
	{
		return number;
	}
	else
	{
		int count = 0;
		while (number != 0)
		{
			number = number >> 1;
			count++;
		}
		return 1 << count;
	}
}

public static int getSum(int[] arr)
{
	int sum =0;
	
	foreach (int i in arr)
	{
		sum +=i;
	}
	return sum;
}

- gkr November 30, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can we use python? If so...

def required_memory(lst):
    used = sum(lst)
    if used % 4 != 0:
        return used // 4 + 1
    return used // 4

- Levin Weinstein April 15, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is there a reason that you can't just use python and say

def memory_required(lst):
    used = sum(lst)
    return used // 4 + 1 if used % 4 else used // 4

- Levin April 15, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

test comment

- Anonymous April 15, 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