Skip to content

Commit f8eaedf

Browse files
author
shobhitbehl
committed
Added Greedy Problem MaximumIncreasingSubarray
1 parent 11722b3 commit f8eaedf

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <bits/stdc++.h>
2+
3+
typedef long long int lli;
4+
5+
using namespace std;
6+
7+
int main()
8+
{
9+
ios_base::sync_with_stdio(false);
10+
cin.tie(NULL);
11+
cout.tie(NULL);
12+
cout.precision(50);
13+
lli n;
14+
cin >> n;
15+
lli a[n];
16+
for(int i = 0; i<n; i++)
17+
{
18+
cin >> a[i];
19+
}
20+
lli ans = 1;
21+
lli out = 1;
22+
for(int i = 1; i<n; i++)
23+
{
24+
if(a[i] > a[i-1])
25+
{
26+
ans++;
27+
}
28+
else
29+
{
30+
ans = 1;
31+
}
32+
out = max(out,ans);
33+
}
34+
cout << out << endl;
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Maximum Increasing Subarray
2+
3+
You are given array consisting of *n* integers. Your task is to find the maximum length of an increasing subarray of the given array.
4+
5+
A subarray is the sequence of consecutive elements of the array. Subarray is called increasing if each element of this subarray strictly greater than previous.

Search/BinarySearch/tags.TPQofa

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
myarray bsearch.cpp /^std::vector<int> myarray;$/;" v
2+
binary_search bsearch.cpp /^bool binary_search(int number)$/;" f
3+
is_digits bsearch.cpp /^bool is_digits(const std::string &str)$/;" f
4+
main bsearch.cpp /^int main(int argc, char const *argv[])$/;" f

0 commit comments

Comments
 (0)