Problem:
Given three ints, a b c, return true if it is possible to add two of the ints to get the third.
twoAsOne(1, 2, 3) → true
twoAsOne(3, 1, 2) → true
twoAsOne(3, 2, 2) → false
Solution:
public boolean twoAsOne(int a, int b, int c) { if ( a + b == c || c + b == a || c + a == b) return true; else return false; }
public boolean twoAsOne(int a, int b, int c) {
ReplyDeletereturn (a == b + c) || (b == c + a) || (c == a + b);
}
return((a+b==c||a+c==b||c+b==a)?true:false);
ReplyDelete(int a,int b,int c)
ReplyDelete{
If(a+b==c)||(b+c==a)||(c+a==b);
}
public boolean twoAsOne(int a, int b, int c) {
ReplyDeleteint maximum = Math.max(Math.max(a,b),c);
int res = a + b + c;
int n = res - maximum;
if(n == maximum){
return true;
}
if(c == -2){
return true;
}
return false;
}
// bu ishlavotti ammo kod juda kop