Skip to content

Commit

Permalink
Time: 52 ms (76.92%) | Memory: 48.9 MB (65.13%) - LeetSync
Browse files Browse the repository at this point in the history
  • Loading branch information
ShatilKhan committed Mar 13, 2024
1 parent fcc76ee commit 2c1f19c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 2571-find-the-pivot-integer/find-the-pivot-integer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @param {number} n
* @return {number}
*/
var pivotInteger = function(n) {
let x = Math.sqrt(n * (n + 1) / 2);

if (x % 1 !== 0) {
return -1;
} else {
return Math.floor(x);
}
};

0 comments on commit 2c1f19c

Please sign in to comment.