爱做梦的老巫婆

关注

LeetCode633.Sum of Square Number(Python)

爱做梦的老巫婆

关注

阅读 43

2022-01-26

167的变形题,也是用两个指针

题解:

class Solution:
    def judgeSquareSum(self, c: int) -> bool:
        a = 0
        b = int(c ** 0.5)
        while a <= b:
            if a ** 2 + b ** 2 == c:
                return True
            elif a ** 2 + b ** 2 > c:
                b = b-1
            else:
                a = a +1
        return False

结果:

 

相关推荐

上善若水的道

[leetcode]633. Sum of Square Numbers

上善若水的道 99 0 0

沉浸在自己的世界里

[leetcode] 633. Sum of Square Numbers

沉浸在自己的世界里 33 0 0

云岭逸人

【Leetcode_easy】633. Sum of Square Numbers

云岭逸人 30 0 0

和谐幸福的人生

Problem 6 Sum square difference (数学)

和谐幸福的人生 25 0 0

豆丁趣

Leetcode 633. 平方数之和

豆丁趣 75 0 0

慕容冲_a4b8

【LeetCode】593. Valid Square 解题报告(Python)

慕容冲_a4b8 43 0 0

耶也夜

【LeetCode】633. 平方数之和

耶也夜 28 0 0

Villagers

leetcode记录-633-平方数之和

Villagers 31 0 0

拾杨梅记

1104. Sum of Number Segments (20)

拾杨梅记 114 0 0

路西法阁下

How to Sum the Number of Files or Folders in a Folder

路西法阁下 86 0 0

精彩评论(0)

0 0 举报