File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Algorithms/523.Continuous-Subarray-Sum Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ class Solution {
2+ public:
3+ bool checkSubarraySum (vector<int >& nums, int k) {
4+ bool flag = false ;
5+ if (k==0 )
6+ flag = true ;
7+ vector<int > dp (nums.size (),0 );
8+ for (int i=0 ;i<nums.size ();i++){
9+ int sum = nums[i];
10+ for (int j=i+1 ;j<nums.size ();j++){
11+ sum += nums[j];
12+ if (flag){
13+ if (sum - k == 0 )
14+ return true ;
15+ }
16+ else {
17+ if (sum % k == 0 )
18+ return true ;
19+ }
20+ }
21+ }
22+ return false ;
23+ }
24+ };
Original file line number Diff line number Diff line change 577577
578578[ 506.Relative-Ranks] ( Algorithms/506.Relative-Ranks/solution.cpp )
579579
580+ [ 523.Continuous-Subarray-Sum] ( Algorithms/523.Continuous-Subarray-Sum/solution.cpp )
581+
580582[ 645.Set-Mismatch] ( Algorithms/645.Set-Mismatch/solution.cpp )
581583
582584[ 674.Longest-Continuous-Increasing-Subsequence] ( Algorithms/674.Longest-Continuous-Increasing-Subsequence/solution.cpp )
You can’t perform that action at this time.
0 commit comments