Please SUBSCRIBE ❤ CODE: class Solution { public: int findLengthOfShortestSubarray(vector<int>& arr) { int n = arr.size(); int i = 0, j = n - 1; while (i + 1 < n && arr[i] <= arr[i + 1]) { ++i; } while (j - 1 >= 0 && arr[j - 1] <= arr[j]) { --j; } if (i >= j) { return 0; } int ans = min(n - 1 - i, j); for (int l = 0; l <= i; ++l) { int r = lower_bound(arr.begin() + j, arr.end(), arr[l]) - arr.begin(); ans = min(ans, r - l - 1); } return ans; } };
@DecodeMaster0114 сағат бұрын
Please SUBSCRIBE❤ CODE : // User function template for C++ class Solution { public: // Function returns the second // largest elements int getSecondLargest(vector<int> &arr) { //Dilemmas Decoder if (arr.size() < 2) { return -1; } int largest = arr[0]; int secondLargest = -1; for (int i = 1; i < arr.size(); ++i) { if (arr[i] > largest) { secondLargest = largest; largest = arr[i]; } else if (arr[i] > secondLargest && arr[i] != largest) { secondLargest = arr[i]; } } return secondLargest; } };
@DecodeMaster01Күн бұрын
Please SUBSCRIBE❤
@DecodeMaster01Күн бұрын
Please SUBSCRIBE❤
@Liferuules014 күн бұрын
Keep Posting
@Liferuules014 күн бұрын
Well Done
@ScaraB01Ай бұрын
Code
@DecodeMaster01Ай бұрын
class Solution { public: // Function to count nodes of a linked list. int getCount(struct Node* head) { int count = 0; struct Node* current = head; while( current != nullptr){ count++; current = current->next; } return count; } };
@DecodeMaster01Ай бұрын
From Tomorrow Onwards i will provide the detailed pdf in description box, from where you can read and understand the concept...and please don't forget to subscribe the channel.
@chad._lifeАй бұрын
nice and readable code keep it up bro
@DecodeMaster01Ай бұрын
Thanks Dear
@SPEED-zq5dw2 ай бұрын
this will only gives the middle if the number are odd in count . if the number count is even it gives first middle but according to question if there is two middle then it should give the second one .
@DecodeMaster012 ай бұрын
The Tortoise and Hare (slow and fast pointer) approach reaches the second middle node when the number of nodes is even. You can read the explanation from this PDF link, which will clear up your doubts. If you still have questions, feel free to ask in the comments section. drive.google.com/file/d/19dIVXYQKiSHwNf3_wBhmCVVlTXF_XeY1/view?usp=drivesdk After reading this PDF, if you still have any doubts, feel free to let me know. Also, please subscribe to the channel if you find it helpful.
@aravatanish31702 ай бұрын
please upload explanation as well
@DecodeMaster012 ай бұрын
Read the explanation from the PDF provided in the description and grasp the approach. If you find any difficulty, feel free to let me know. And don't forget to subscribe to the channel for more videos-your support means a lot! Join Telegram Channel for more updates, link is in description...