## Amazon Interview Question for Java Developers

• 0

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

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.

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)
}``````

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;
}``````

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

why min = 1?

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;
}
}

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``````

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.

### 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.