53. 最大子数组和 - 给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 子数组 是数组中的一个连续部分。 示例 1: 输入:nums = [-2,1,-3,4,-1,2,1,-5,4] 输出:6 解释:连续子数组 [4,-1,2,1] 的和最大,为
121. 买卖股票的最佳时机 给定一个数组prices,它的第i个元素prices[i]表示一支给定股票第i天的价格。 你只能选择某一天买入这只股票,并选择在未来的某一个不同的日子卖出该股票。设计一个算法来计算你所能获取的最大利润。 返回你可以从这笔交易中获取的最大利润。如果你不能获取任何利润,返回0。 示例1: 输入...
输入:arr=[1024,512,256,128,64,32,16,8,4,2,1]输出:[1,2,4,8,16,32,64,128,256,512,1024]解释:数组中所有整数二进制下都只有1个1,所以你需要按照数值大小将它们排序。 示例3: 输入:arr=[10000,10000]输出:[10000,10000]示例4: 输入:arr=[2,3,5,7,11,13,17,19]输出:[2,3,5,17,7,1...
LeetCode - 728. 自除数 https://leetcode-cn.com/problems/self-dividing-numbers/ 题目描述 自除数 是指可以被它包含的每一位数除尽的数。 例如,128 是一个自除数,因为128%1==0,128%2==0,128%8==0。 还有,自除数不允许包含 0 。 给定上边界和下边界数字,输出一个列表,列表的元素是边界(含边界)内所...
Can you solve this real interview question? Find Winner on a Tic Tac Toe Game - Tic-tac-toe is played by two players A and B on a 3 x 3 grid. The rules of Tic-Tac-Toe are: * Players take turns placing characters into empty squares ' '. * The first pla
// https://leetcode.cn/problems/find-nearest-right-node-in-binary-tree/description/ // 1602. 找到二叉树中最近的右侧节点 #include<iostream> #include<queue> using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode() : val(0), left(nullptr), right(null...
LeetCode Problems' Solutions . Contribute to xiang1563/leetcode development by creating an account on GitHub.
About LeetCode Problems' Solutions Resources Readme Activity Stars 0 stars Watchers 0 watching Forks 0 forks Report repository Releases No releases published Packages No packages published Languages C++ 87.4% Java 8.3% Python 2.8% Shell 1.5% ...
链接:https://leetcode-cn.com/problems/find-all-anagrams-in-a-string 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20.
题目难度:Easy 通过率:70.20% 相关话题 数学 https:///tag/math 相似题目 完美数 https:///problems/perfect-number/难度:简单 解题思路: 设计一个判断单个数是否是自除数的函数,比如取名为IsSelfDIv() IsSelfDIv函数的要点是: 排除数位中含有0的数