-
Notifications
You must be signed in to change notification settings - Fork 10
MinimumSubarrayWithTarget #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Create Longest Substring Without Repeating Characters
Code of Longest Substring Without Repeating Characters
int n=vect.size(); | ||
int target=14; | ||
int minlen=INT_MAX; | ||
int ans = MinimumSubarrayWithTarget(vect,target,minlen); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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++) { |
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user camelCasing like minLength
Use class structure and not. Please look at the code of NoRepearSubstring. Also give a proper name to class & file like: |
51692fe
to
931628d
Compare
No description provided.