From a2978fc785720cbc43c9c2f0e86a94f848ec1cce Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 23 Feb 2021 00:06:58 +0800 Subject: import(solutions): Add editor config. --- works/solutions/.editorconfig | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 works/solutions/.editorconfig (limited to 'works/solutions/.editorconfig') diff --git a/works/solutions/.editorconfig b/works/solutions/.editorconfig new file mode 100644 index 0000000..0cc28a1 --- /dev/null +++ b/works/solutions/.editorconfig @@ -0,0 +1,2 @@ +[*.cpp] +tab_width = 2 -- cgit v1.2.3 From 02df09d6e18db2380028e82923ccaba3bfbbec0d Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 5 Apr 2021 20:45:07 +0800 Subject: import(solutions): Add leetcode 69. --- works/solutions/.editorconfig | 3 +++ works/solutions/leetcode/cpp/69.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 works/solutions/leetcode/cpp/69.c (limited to 'works/solutions/.editorconfig') 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; +} -- cgit v1.2.3