leetcode new problems

This commit is contained in:
2026-02-11 14:48:41 +05:30
parent 192ce44a81
commit 0f52d46c67
29 changed files with 658 additions and 5 deletions
+20
View File
@@ -0,0 +1,20 @@
class Solution {
public :
bool isTrionic(vector<int> &nums){
int n =nums.size();
if(n<3) return false;
int p = 0;
int q = n-1;
while(p+1 <n && nums[p] < nums[p+1]) p++;
while(q-1>=0 && nums[q] > nums[q-1]) q--;
if(p==0 || q==n-1) return false;
while(p+1<=q){
if(nums[p] > nums[p+1]) p++;
else return false;
}
return p==q;
}
};
// Uses two pointers, TC : o(n) , SC : o(1)
// finds valid p and q if they exist, adn checks for strictly decreasing between p...q