0% found this document useful (0 votes)
2 views3 pages

In Video Problems

The document contains three code snippets related to array manipulation in C++. The first snippet reverses a portion of an array, the second rotates an array by a given number of positions, and the third checks if an array is sorted or can be sorted by at most one rotation. Each function is implemented within a class structure and utilizes standard vector operations.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

In Video Problems

The document contains three code snippets related to array manipulation in C++. The first snippet reverses a portion of an array, the second rotates an array by a given number of positions, and the third checks if an array is sorted or can be sorted by at most one rotation. Each function is implemented within a class structure and utilizes standard vector operations.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

PROBLEMS

void reverseArray(vector<int> &arr , int m)


{
int start=m+1;
int end=[Link]()-1;
while(start<=end)
{
swap(arr[start],arr[end]);
start++;
end--;
}
}
class Solution {
public:
void rotate(vector<int>& nums, int k) {
vector<int> temp([Link]());
for(int i=0;i<[Link]();i++)
{
temp[(i+k)%[Link]()]=nums[i];
}
// copying element of temp in nums
nums=temp;

}
};
class Solution {
public:
bool check(vector<int>& nums) {
int n=[Link]();
int count=0;
for(int i=1;i<n;i++)
{
if(nums[i-1]>nums[i])
count++;
}
if(nums[n-1]>nums[0])
{
count++;
}

/* if(count<=1)
{return true;
}
else{
return false;
}*/

return count<=1;

}
};

You might also like