Skip to content

Commit dd1fd52

Browse files
authored
Update find-the-pivot-integer.cpp
1 parent 561cd6e commit dd1fd52

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

C++/find-the-pivot-integer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class Solution {
66
public:
77
int pivotInteger(int n) {
8-
int x = sqrt((n + 1) * n / 2);
8+
int x = sqrt((n + 1) * n / 2) + 0.5;
99
return x * x == (n + 1) * n / 2 ? x : -1;
1010
}
1111
};

0 commit comments

Comments
 (0)