Search
 
SCRIPT & CODE EXAMPLE
 

CPP

sliding window c++

int maxSum(int arr[], int n, int k)
{
    // Initialize result
    int max_sum = INT_MIN;
  
    // Consider all blocks starting with i.
    for (int i = 0; i < n - k + 1; i++) {
        int current_sum = 0;
        for (int j = 0; j < k; j++)
            current_sum = current_sum + arr[i + j];
  
        // Update result if required.
        max_sum = max(current_sum, max_sum);
    }
  
    return max_sum;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ hash map key count 
Cpp :: c++ while loop 
Cpp :: Euler constant 
Cpp :: intersection between vector c++ 
Cpp :: move elements from vector to unordered_set 
Cpp :: prime number program c++ 
Cpp :: C++ Quotient and Remainder 
Cpp :: c++ online compiler 
Cpp :: C++ rename function 
Cpp :: tabeau pseudo dynamique sur c++ 
Cpp :: len in cpp 
Cpp :: find first of a grammar 
Cpp :: or in c++ 
Cpp :: cpp vector structure 
Cpp :: free a pointer c++ 
Cpp :: definition of singly linkedlist 
Cpp :: tr bash 
Cpp :: max circular subarray sum gfg practice 
Cpp :: virtual function in c++ 
Cpp :: c++ segmentation fault 
Cpp :: Programming Languages codechef solution in c++ 
Cpp :: read a file line by line c++ struct site:stackoverflow.com 
Cpp :: error: use of parameter outside function body before ] token c++ 
Cpp :: c++ solver online free 
Cpp :: Corong_ExerciseNo3 
Cpp :: const in c++ is same as globle in python 
Cpp :: cout ascii art c++ 
Cpp :: how to measure cpp code performace 
Cpp :: and condtion c++ 
Cpp :: sfml time set 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =