class Solution{
public:
vector<int> find3Numbers(vector<int> arr, int N) {
// Your code here
vector<int>v;
int left=INT_MAX;
int mn=left;
int mid=INT_MAX;
if(N<3)
{
return {};
}
for(int i=0;i<N;i++)
{
if(arr[i]<left)
{
left=arr[i];
}
else if(arr[i]>left&&arr[i]<mid)
{
mid=arr[i];
mn=left;
}
else if(arr[i]>mid)
{
v.push_back(mn);
v.push_back(mid);
v.push_back(arr[i]);
return v;
}
}
return {};
}
};
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter