Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Week1/Monotonic Array/week1_pooja
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Solution {
public:
bool isMonotonic(vector<int>& A) {

return A[0] <= A[A.size() - 1] ? isIncreasing(A) : isDecreasing(A);
}

bool isIncreasing(vector<int>& A){

for(int i = 1; i < A.size(); i++)
if(A[i - 1] > A[i])
return false;
return true;
}

bool isDecreasing(vector<int>& A){

for(int i = 1; i < A.size(); i++)
if(A[i - 1] < A[i])
return false;
return true;
}
};