diff options
| author | crupest <crupest@outlook.com> | 2021-04-05 20:45:07 +0800 | 
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2021-04-05 20:45:07 +0800 | 
| commit | 02df09d6e18db2380028e82923ccaba3bfbbec0d (patch) | |
| tree | cec9ec9e1d23dd68b8d25a371cc1ceafeebc7a22 | |
| parent | b0cb34e532c7b94d04cda246d2080bafd86aad38 (diff) | |
| download | crupest-02df09d6e18db2380028e82923ccaba3bfbbec0d.tar.gz crupest-02df09d6e18db2380028e82923ccaba3bfbbec0d.tar.bz2 crupest-02df09d6e18db2380028e82923ccaba3bfbbec0d.zip | |
import(solutions): Add leetcode 69.
| -rw-r--r-- | works/solutions/.editorconfig | 3 | ||||
| -rw-r--r-- | works/solutions/leetcode/cpp/69.c | 14 | 
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;
 +}
 | 
