maximum subarray sum equal with K in c++
C++
int maxsubarraysumequaltoX(int A[], int N, int X) {
int i = 0, j = 0, best = A[0], res = 0;
while (j < N) {
if (best == X) res = max(res, j-i+1);
if (best <= X) {
if (j < N-1) best += A[++j];
else j++;
}
else best -= A[i++];
}
return res;
}
Also in C++:
- Title
- hashmap in c++
- Category
- C++
- Title
- delete files c++
- Category
- C++
- Title
- memset
- Category
- C++
- Title
- phph date
- Category
- C++
- Title
- nth_element c++
- Category
- C++
- Title
- rgb(100,100,100,0.5) validation c++
- Category
- C++
- Title
- substr c++
- Category
- C++
- Title
- c++ function return pointer to itself
- Category
- C++
- Title
- what is difference between ciel and floor
- Category
- C++
- Title
- : error: ‘cont’ cannot be used as a function return (cont(cont-1))/2;
- Category
- C++
- Title
- make an x using asterisk c++
- Category
- C++
- Title
- Find a element in a map C++
- Category
- C++
- Title
- comparing strings c++
- Category
- C++
- Title
- heap in cpp stl
- Category
- C++
- Title
- how to initialize a vector in c++
- Category
- C++
- Title
- fmod c++
- Category
- C++
- Title
- function template
- Category
- C++
- Title
- empty string c++ value
- Category
- C++
- Title
- c++ give options
- Category
- C++
- Title
- char* to int in cpp
- Category
- C++
- Title
- free or delete in c++
- Category
- C++
- Title
- how to convert string into number
- Category
- C++
- Title
- append string to another string c++
- Category
- C++
- Title
- c++ round to int
- Category
- C++
- Title
- Merge k sorted linked lists and return it as one sorted list.
- Category
- C++
- Title
- c++ for loop syntax
- Category
- C++
- Title
- remove from unordered_set c++
- Category
- C++
- Title
- best fit algorithm
- Category
- C++
- Title
- c++ crash windows
- Category
- C++
- Title
- how to remove maximum number of characters in c++ cin,ignore
- Category
- C++
- Title
- sfml base program
- Category
- C++
- Title
- create new file c++
- Category
- C++
- Title
- c++ how to make a negative float positive
- Category
- C++
- Title
- unsorted array to bst
- Category
- C++
- Title
- command line options in c++
- Category
- C++
- Title
- c++ delete dynamically allocated array
- Category
- C++
- Title
- initialize int c++
- Category
- C++
- Title
- c++ excel cell blank cells
- Category
- C++
- Title
- longest common subsequence
- Category
- C++
- Title
- maximum subarray sum equal with K in c++
- Category
- C++
- Title
- dfs in c++
- Category
- C++
- Title
- body parser
- Category
- C++
- Title
- pairs in c++
- Category
- C++
- Title
- peak in c++
- Category
- C++
- Title
- fast input output in c++
- Category
- C++
- Title
- how to append one vector to another c++
- Category
- C++
- Title
- how to swap string characters in c++
- Category
- C++
- Title
- c++ files
- Category
- C++
- Title
- c++ isalphanum
- Category
- C++
- Title
- cs1955 unity vector3
- Category
- C++
- Title
- what is meaning of 64 bit integer in c++
- Category
- C++
- Title
- vertical traversal of binary tree
- Category
- C++
- Title
- tuple c++
- Category
- C++
- Title
- uepic games github
- Category
- C++
- Title
- c++ while true loop
- Category
- C++
- Title
- c++ switch case statement
- Category
- C++
- Title
- initialize 3d vector c++
- Category
- C++
- Title
- how to compile opencv c++ in ubuntu
- Category
- C++
- Title
- shuffle vector c++
- Category
- C++
- Title
- c++ ambigous error
- Category
- C++
- Title
- how to iterate through array in c++
- Category
- C++
- Title
- 2d vector
- Category
- C++
- Title
- jump to case label c++
- Category
- C++
- Title
- how to include seld declared header file in c++
- Category
- C++
- Title
- char **
- Category
- C++
- Title
- lopping over an array c++
- Category
- C++
- Title
- how to allocate on heap in c++
- Category
- C++
- Title
- C++ pointer arithmetic
- Category
- C++
- Title
- modulo c++
- Category
- C++
- Title
- c++ smart pointer 2d array
- Category
- C++
- Title
- set in c++
- Category
- C++
- Title
- map.erase in c++
- Category
- C++
- Title
- preorder traversal c++
- Category
- C++
- Title
- counting valleys hackerrank solution in c++
- Category
- C++
- Title
- coronavirus
- Category
- C++
- Title
- c++ declare variable
- Category
- C++
- Title
- kruskal c++
- Category
- C++
- Title
- howt o initialize 3d vector in c++
- Category
- C++
- Title
- accept the noun and the output of plural c++
- Category
- C++
- Title
- c++ iterate over vector
- Category
- C++
- Title
- loop through words in string c++
- Category
- C++
- Title
- c++ create object
- Category
- C++
- Title
- reverse in vector c++
- Category
- C++
- Title
- c++ do while loop
- Category
- C++
- Title
- how to output text in c++
- Category
- C++
- Title
- how to make a n*n 2d dynamic array in c++
- Category
- C++
- Title
- 2927260.eps 2927262.jpg 2927263.ai License free.txt License premium.txt
- Category
- C++
- Title
- sfml basic program
- Category
- C++
- Title
- C++ user input
- Category
- C++
- Title
- C++ sfinae
- Category
- C++
- Title
- insertion c++
- Category
- C++
- Title
- goto c++
- Category
- C++
- Title
- ue4 modular character
- Category
- C++
- Title
- find_if c++
- Category
- C++
- Title
- c++ over load oprator to print variable of clas
- Category
- C++
- Title
- pair in c++
- Category
- C++
- Title
- power c++
- Category
- C++
- Title
- c++ comment
- Category
- C++
- Title
- cout console
- Category
- C++
- Title
- C++ Syntax
- Category
- C++