Amazon Interview Question for Java Developers


Country: United States




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

There are 2 scenarios to consider,
1. You cannot create new coins
2. You cannot break down existing coins

The solution you provide addressed #1 but not #2.

Eg. {1,4} answer should be 2 not 5

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

Do you have an answer then? The question doesn't say those scenarios you've mentioned.

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

//in javascript
let a=[1,2,5,8]
    
    for(let i=1;;i++){
        let j=i;
        while(a.indexOf(j)<0){    
            console.log(j+' la so ko co trong arr')
            let k=a.reduce((a,b)=>{
                        return b>=j?a:a+b
                });
            console.log('tong la: '+k)
                if(j<=k/2) break;
                else j=k-j;
            if(a.indexOf(j)>=0||j==0) break;
            if(j<Math.min(...a)) return i;
            }          
            
        console.log('khong tim thay voi: '+i)
    }

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

public Integer minSum(int[] arr) {
    Integer minSum = 1;
    for (int i = 0 ; i < arr.length ; i++) {
        if minSum < arr[i] {
            return minSum;
        } else {
            minSum += arr[i];
        }
    }
    return minSum;
}

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

why min = 1?

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

static int minSum(int[] intArr) {
if (intArr[0]>1) {
return 1;
}
else {
int prev = 1;
for(int i=1; i<intArr.length; i++) {
if ( prev+1 < intArr[i] ) {
break;
}
prev+=intArr[i];
}
return prev+1;
}
}

- lei.han April 23, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

def minimumvalue(list):
      		sum=0
    		for i in list:
        	sum=sum+i
    		return sum+1

- Dhioyt April 18, 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