File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ int Solution::maxSubArray (const vector<int > &A) {
2
+ int maxi = INT_MIN;
3
+ int sum = 0 ;
4
+ for (int i = 0 ; i < A.size (); i++){
5
+ sum = sum + A[i];
6
+ maxi = max (maxi, sum);
7
+ if (sum < 0 ) sum = 0 ;
8
+ }
9
+ return maxi;
10
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ string stuff (string s, int fsz);
5
+ void deStuff (string s);
6
+
7
+ int main (){
8
+ string st, s;
9
+ int fsz;
10
+ cout << " Enter the data := " ;
11
+ cin >> s;
12
+ cout << " Enter the frame size := " ;
13
+ cin >> fsz;
14
+ st = stuff (s, fsz);
15
+ deStuff (st);
16
+ return 0 ;
17
+ }
18
+
19
+ string stuff (string s, int fsz){
20
+ int nof, n;
21
+ string st;
22
+ nof = (s.size ()/(fsz-2 ))+1 ;
23
+ n = s.size () + nof*2 ;
24
+ int indx = 0 ;
25
+ bool flag = false ;
26
+ for (int i = 0 ; i < n; i++){
27
+ if (i%fsz==0 ) st+=' #' ;
28
+ else if (i%fsz==fsz-1 ) st+=' #' ;
29
+ else {
30
+ if (s[indx]==' \0 ' ){
31
+ flag = true ;
32
+ break ;
33
+ }
34
+ st+=s[indx];
35
+ indx++;
36
+ }
37
+ }
38
+ if (flag) st += ' #' ;
39
+ cout << " Stuffed data := " << st << " \n " ;
40
+ return st;
41
+ }
42
+
43
+ void deStuff (string s){
44
+ string deSt;
45
+ for (int i = 0 ; i < s.size (); i++){
46
+ if (s[i]!=' #' ) deSt+=s[i];
47
+ }
48
+ cout << " DeStuffed data := " << deSt << " \n " ;
49
+ }
You can’t perform that action at this time.
0 commit comments