![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
模运算
文章平均质量分 77
memcpy0
希望探索文理结合的自由之路。
展开
-
LeetCode 342. Power of Four【迭代/位操作/数学/打表】简单
Given an integer n, return true if it is a power of four. Otherwise, return false. An integer n is a power of four, if there exists an integer x such that n == 4x. Example 1: Input: n = 16 Output: true Example 2: Input: n = 5 Output: false Example 3: I原创 2021-05-31 02:44:20 · 548 阅读 · 1 评论 -
LeetCode C++ 1018. Binary Prefix Divisible By 5【Array】简单
Given an array A of 0s and 1s, consider N_i: the i-th subarray from A[0] to A[i] interpreted as a binary number (from most-significant-bit to least-significant-bit.) Return a list of booleans answer, where answer[i] is true if and only if N_i is divisible原创 2021-01-15 12:10:14 · 172 阅读 · 1 评论 -
LeetCode C++ 1497. Check If Array Pairs Are Divisible by k【Math/Hash Table】中等
Given an array of integers arr of even length n and an integer k. We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k. Return True If you can find a way to do that or False otherwise. Example 1: Input:原创 2020-12-08 01:21:50 · 255 阅读 · 0 评论 -
LeetCode C++ 523. Continuous Subarray Sum【哈希表/前缀和/模运算】中等
Given a list of non-negative numbers and a target integer k , write a function to check if the array has a continuous subarray of size at least 2 that sums up to a multiple of k , that is, sums up to n*k where n is also an integer. Example 1: Input: [23,原创 2020-09-23 20:29:26 · 226 阅读 · 0 评论 -
LeetCode 1590. Make Sum Divisible by P【前缀和,哈希表,数论】中等
Given an array of positive integers nums , remove the smallest subarray (possibly empty) such that the sum of the remaining elements is divisible by p . It is not allowed to remove the whole array. Return the length of the smallest subarray that you need t原创 2020-09-23 15:21:13 · 473 阅读 · 0 评论