aboutsummaryrefslogtreecommitdiff
path: root/works
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-04-05 20:45:07 +0800
committercrupest <crupest@outlook.com>2021-04-05 20:45:07 +0800
commit889c67b8c784f4a9829ab2fdb5b68985aaefefb4 (patch)
tree70561a1087ca12dad1a376eb22877a9dc024a3b5 /works
parent70c164dd367c23bb1a0b373e5bbb40068e0a036b (diff)
downloadcrupest-889c67b8c784f4a9829ab2fdb5b68985aaefefb4.tar.gz
crupest-889c67b8c784f4a9829ab2fdb5b68985aaefefb4.tar.bz2
crupest-889c67b8c784f4a9829ab2fdb5b68985aaefefb4.zip
import(solutions): Add leetcode 69.
Diffstat (limited to 'works')
-rw-r--r--works/solutions/.editorconfig3
-rw-r--r--works/solutions/leetcode/cpp/69.c14
2 files changed, 17 insertions, 0 deletions
diff --git a/works/solutions/.editorconfig b/works/solutions/.editorconfig
index 0cc28a1..28365d2 100644
--- a/works/solutions/.editorconfig
+++ b/works/solutions/.editorconfig
@@ -1,2 +1,5 @@
+[*.c]
+tab_width = 2
+
[*.cpp]
tab_width = 2
diff --git a/works/solutions/leetcode/cpp/69.c b/works/solutions/leetcode/cpp/69.c
new file mode 100644
index 0000000..9914fff
--- /dev/null
+++ b/works/solutions/leetcode/cpp/69.c
@@ -0,0 +1,14 @@
+int mySqrt(int x) {
+ long long l = 0, r = x;
+
+ while (l != r) {
+ long long m = (l + r + 1) / 2;
+ if (m * m <= x) {
+ l = m;
+ } else {
+ r = m - 1;
+ }
+ }
+
+ return l;
+}