์ด๋ฒ์๋ ์ฝ๋ฉ๋ฐ์ฅ ๋ท์ปด์ loneSum ๋ฉ์๋๋ฅผ ๊ตฌํํด ๋ณด์์ต๋๋ค.
๋ฌธ์ ๋ ์ด๊ณณ์ ๊ฐ์๋ฉด ํ์ธ๊ฐ๋ฅํฉ๋๋ค.
public int loneSum(int a, int b, int c) {
int sum = 0;
sum += a;
if ( a == b ){
sum -= b;
}else{
sum += b;
}
if ( a== c || b == c ){
sum -= c;
}else{
sum+= c;
}
return ( sum < 0 ? 0 : sum );
}
'๐ป Programming > Java' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์๊ณ ๋ฆฌ์ฆ/๋ฌธ์ ํ์ด] CodingBat Array-3 fix34 (0) | 2015.04.22 |
---|---|
[์๊ณ ๋ฆฌ์ฆ/๋ฌธ์ ํ์ด] CodingBat Array-3 maxSpan (0) | 2015.04.22 |
[์๊ณ ๋ฆฌ์ฆ/๋ฌธ์ ํ์ด] CodingBat Logic-2 noTeenSum (0) | 2015.04.22 |
[์๊ณ ๋ฆฌ์ฆ/๋ฌธ์ ํ์ด] CodingBat Logic-2 luckySum (2) | 2015.04.22 |
[์๊ณ ๋ฆฌ์ฆ/๋ฌธ์ ํ์ด] CodingBat Logic-2 makeBricks (0) | 2015.04.22 |