Skip to content

Instantly share code, notes, and snippets.

@allenhwkim
Created July 4, 2022 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allenhwkim/7e809a89b859892fb7d2570fef4efb3d to your computer and use it in GitHub Desktop.
Save allenhwkim/7e809a89b859892fb7d2570fef4efb3d to your computer and use it in GitHub Desktop.
function solution(A) {
if (A.length < 3) return 0;
A = A.sort( (a,b) => a - b)
for (var i=0; i< A.length -2; i++) {
const [p, q, r] = A.slice(i, i+3)
if ( (p + q) > r && (p+r) > q && (q+r) > p)
return 1
}
return 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment