September 26, 2020
  • 5:49 am Cách cài Win từ ổ cứng: cả Win 7/8/8.1 và Win10 (làm mẫu với Win 10)
  • 2:47 am [Topgame] Top 9 game bắn súng online miễn phí hay nhất đầu 2018 | Android-IOS
  • 8:03 pm Hướng dẫn tạo chú thích footnote trong Word | How to Insert Footnote in Word
  • 7:26 am Cách chèn nhạc vào ảnh và video trên Facebook
  • 6:59 am Tóm Tắt The Walking Dead (Xác Sống) | Season 4



GoodTecher LeetCode Tutorial 69. Sqrt(x) (Java)

LeetCode Tutorial by GoodTecher. The tutorial provides a step-by-step demonstration on how to solve coding problems.

Complete Playlist for the GoodTecher LeetCode Tutorial:

GoodTecher Website:

GoodTecher Channel on YouTube:

GoodTecher Github:

Nguồn: https://chaoticpharmacology.com/

Xem thêm bài viết khác: https://chaoticpharmacology.com/cong-nghe/

admin

RELATED ARTICLES

5 COMMENTS

  1. Ash Winchester Posted on July 11, 2020 at 6:49 pm

    bad solution, do not use this. instead check this solution:

    class Solution {
    public int mySqrt(int x) {
    if (x < 2) return x;

    long num;
    int pivot, left = 2, right = x / 2;
    while (left <= right) {
    pivot = left + (right – left) / 2;
    num = (long)pivot * pivot;
    if (num > x) right = pivot – 1;
    else if (num < x) left = pivot + 1;
    else return pivot;
    }

    return right;
    }
    }

    Reply
  2. Mr. Mystiks Posted on July 11, 2020 at 6:49 pm

    This code actually doesn’t work for the test case: X=8. It goes into an infinite loop. This is garbage code and I don’t think you even understand the solution.

    Reply
  3. Ashwini Khedkar Posted on July 11, 2020 at 6:49 pm

    For the case when x = 8, above code, goes into an infinite loop causing time limit to exceed.

    Reply
  4. Abdelrahman Posted on July 11, 2020 at 6:49 pm

    why did you use lo+1 ?

    Reply
  5. Kun Jiang Posted on July 11, 2020 at 6:49 pm

    看了很多不同的视频 你的概念思路是讲的最好的 非常清楚 感谢 请继续 并且可以把70题加上吗?

    Reply
LEAVE A COMMENT