【LeetCode】633. Sum of Square Numbers】的更多相关文章

Difficulty: Easy  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/sum-of-square-numbers/submissions/ Given a non-negative integer c, your task is to decide whether there're two integers aand b such that a2 + b2 = c. Example 1: Inpu…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双指针 列表生成式 循环 日期 题目地址:https://leetcode.com/problems/sum-of-square-numbers/discuss/ 题目描述 Given a non-negative integer c, your task is to decide whether there're two integers a an…
Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c. 只要是two_sum 变形 都可以考虑用hash_set来做. class Solution { public: bool judgeSquareSum(int c) { //这个和两数之和很想 感觉是两数之和的变形 //先求一组两平方和之数 如果这两平方和数都存在的话 就返回true //用has…
problem 633. Sum of Square Numbers 题意: solution1: 可以从c的平方根,注意即使c不是平方数,也会返回一个整型数.然后我们判断如果 i*i 等于c,说明c就是个平方数,只要再凑个0,就是两个平方数之和,返回 true:如果不等于的话,那么算出差值 c - i*i,如果这个差值也是平方数的话,返回 true.遍历结束后返回 false, class Solution { public: bool judgeSquareSum(int c) { ; --…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 暴力 找规律 日期 题目地址:https://leetcode.com/problems/sum-of-even-numbers-after-queries/ 题目描述 We have an array A of integers, and an array queries of queries. For the i-th query val = q…
题目如下: We have an array A of integers, and an array queries of queries. For the i-th query val = queries[i][0], index = queries[i][1], we add val to A[index].  Then, the answer to the i-th query is the sum of the even values of A. (Here, the given ind…
[LeetCode]129. Sum Root to Leaf Numbers 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/sum-root-to-leaf-numbers/description/ 题目描述: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a numbe…
[LeetCode]201. Bitwise AND of Numbers Range 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/bitwise-and-of-numbers-range/description/ 题目描述: Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers i…
题目如下: 解题思路:我的想法对于数组中任意一个元素,找出其左右两边最近的小于自己的元素.例如[1,3,2,4,5,1],元素2左边比自己小的元素是1,那么大于自己的区间就是[3],右边的区间就是[4,5].那么对于元素2来说,和左边区间合并组成[2,3]以及和右边区间合并组成[2,4,5],这两段区间包括2在内的所有subarray的最小值都是2,其分别可以组成的subarry的个数是 len([3])和len([4,5]),左右区间合并在一起可以组成的subarray的个数是len([3])…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 DFS 日期 题目地址:https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/ 题目描述 Given a binary tree, each node has value 0 or 1. Each root-to-leaf path represents a binary n…