GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Algorithm/leetcode_solved/leetcode_0069_Sqrt(x).cpp at master · OneCodeMonkey/Algorithm

Expand file tree

/

leetcode_0069_Sqrt(x).cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
20 lines (19 loc) · 459 Bytes
/

leetcode_0069_Sqrt(x).cpp

Copy path

File metadata and controls

20 lines (19 loc) · 459 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
* AC:
* Runtime: 4 ms, faster than 74.90% of C++ online submissions for Sqrt(x).
* Memory Usage: 8 MB, less than 100.00% of C++ online submissions for Sqrt(x).
* 思路:牛顿法,开方求平方根近似值的常用手法。
*
*/
class Solution {
public:
int mySqrt(int x) {
if(x == 0)
return 0;
long raw = x;
while(raw * raw > x) {
raw = (raw + x / raw) / 2;
}
return raw;
}
};
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.