Skip to content

Conversation

Lonewolf0502
Copy link

No description provided.

int n=vect.size();
int target=14;
int minlen=INT_MAX;
int ans = MinimumSubarrayWithTarget(vect,target,minlen);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't pass anything in the function other than arr and target. Declare everything in the function itself and not in the main method.

#include<bits/stdc++.h>
using namespace std;

int MinimumSubarrayWithTarget(vector<int>vect,int target,int minlen) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use space after commas.


int windowStart = 0;
int windowSum = 0;
for(int windowEnd = 0; windowEnd < vect.size(); windowEnd++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call the array as arr or nums not vect.

int windowSum = 0;
for(int windowEnd = 0; windowEnd < vect.size(); windowEnd++) {
windowSum += vect[windowEnd];
while(windowSum>=target){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use proper space between the operands.

vector<int>vect={3,4,7,1,9,2,12,1};
int n=vect.size();
int target=14;
int minlen=INT_MAX;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user camelCasing like minLength

@aakashverma1124
Copy link
Owner

Use class structure and not. Please look at the code of NoRepearSubstring. Also give a proper name to class & file like:
MinimumSubarrayWithGreaterOrEqualToTarget.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants