Amazon Interview Question for SDE1s


Country: India
Interview Type: Written Test




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

<script>alert(1)</script>

- Anonymous August 27, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

4*underroot(N)

- Khattter September 03, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

solve for k^3 - k^2 = n where n is the number of apples. return 4k.

- keennewbie September 08, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

// Returns Perimeter Value Necessary to Have N Apples Inside the Plot 
   public int applesPerimeter(int N) {
        int p;
        // Handle Even N
        if (N % 2 == 0) {
            p = (N / 2);
            return p * 4;
        // Handle Odd N
        } else {
            p = (N / 2);
            return (p * 4) + 2;
        }
    }

- AEK September 11, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

perfect

- Eduardo March 17, 2024 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public int findPerimeter(int n) {

// accumulator
int accumulator = 0;

// side
int side = 0;

// loop while counter < number of apples
while (accumulator < n) {

// add one unit to side
side++;

// each time you add 1 unit to the side, you add:
// 2*side apples +
// 2*(2*side -1) apples + 2*(2*side -2) apples... + 2*(side) apples

// update accumulator with 2*side
accumulator = accumulator + 2*side;

// loop from 2*side-1 to side
int i=side*2 - 1;

while(i>=side) {

// update accumulator
accumulator = accumulator + 2*i;

// subtract counter
i--;
}

}

// return the perimeter = 4 * side
return 4*side;
}

}

- Jota February 18, 2020 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public int findPerimeter(int n) {
		
		// accumulator
		int accumulator = 0;
		
		// side 
		int side = 0;
		
		// loop while counter < number of apples
		while (accumulator < n) {
			
			// add one unit to side
			side++;
			
			// each time you add 1 unit to the side, you add:
			// 2*side apples +
			// 2*(2*side -1) apples + 2*(2*side -2) apples... + 2*(side) apples
			
			// update accumulator with 2*side
			accumulator = accumulator + 2*side;
			
			// loop from 2*side-1 to side
			int i=side*2 - 1;
			
			while(i>=side) {
				
				// update accumulator
				accumulator = accumulator + 2*i;
				
				// subtract counter
				i--;
			}
			
		}
		
		// return the perimeter = 4 * side
		return 4*side;
	}

}

- Jota February 18, 2020 | 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