Skip to content

Instantly share code, notes, and snippets.

@goesang
Last active November 8, 2015 09:31
Show Gist options
  • Save goesang/c1dac5232abf1ee13d94 to your computer and use it in GitHub Desktop.
Save goesang/c1dac5232abf1ee13d94 to your computer and use it in GitHub Desktop.
3Sum 문제 자바스크립트 해답.
var arr = [-1,0 ,1, 2, -1, -4];
for(var i = 0 ; i<arr.length;i++){
var a= arr[i];
for(var j = i ; j<arr.length-1;j++){
var b= arr[j];
for(var k = j ; k<arr.length-2;k++){
var c= arr[k];
if((a<=b && b<=c) &&a+b+c == 0)
alert(a+" "+b+" "+c);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment