BS-6. Minimum in Rotated Sorted Array

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ต.ค. 2024

ความคิดเห็น • 395

  • @takeUforward
    @takeUforward  ปีที่แล้ว +79

    Please comment understood and give us a like if you got everything :)

    • @vishnusiddarth7953
      @vishnusiddarth7953 ปีที่แล้ว +1

      mass

    • @sudhanshushekhar4222
      @sudhanshushekhar4222 ปีที่แล้ว +1

      Understood

    • @ersoumyajitpan7205
      @ersoumyajitpan7205 ปีที่แล้ว +1

      ************ more optimized ************
      int findMin(vector& nums){
      int left = 0, right = nums.size() - 1;
      while (left < right) {
      int mid = left + (right - left) / 2;
      if (nums[mid] > nums[right]) {
      left = mid + 1;
      } else {
      right = mid;
      }
      }
      return nums[left];
      }

    • @adil_k
      @adil_k ปีที่แล้ว +1

      East or west. Striver is the best

    • @aladdinstudios2735
      @aladdinstudios2735 9 หลายเดือนก่อน +1

      I came only for Minimum in Rotated Sorted Array so why I would seen previews video #striver ?

  • @shivajirao999
    @shivajirao999 4 หลายเดือนก่อน +67

    the feeling of writing the exact same code by your own without even looking at the lecture is insane, ALL thanks to your level of explanation

    • @ravikr3463
      @ravikr3463 4 หลายเดือนก่อน +4

      Abe easy hai ye upper ke 3 phele se kiye hue the esiliyee btw good

    • @Rahul_Mongia
      @Rahul_Mongia 4 หลายเดือนก่อน

      @@ravikr3463

    • @akshatgupta8787
      @akshatgupta8787 3 วันที่ผ่านมา

      @@ravikr3463 bhai merse wo karne ke baad bhi nahi hua yrr

  • @abhishekverma7604
    @abhishekverma7604 ปีที่แล้ว +187

    guys, this is one of the most important question if u r preparing for amazon and adobe.. hell they asked it a lot in previous 6 months according to Leetcode stats..

  • @akshitbhasin7322
    @akshitbhasin7322 11 หลายเดือนก่อน +16

    The fact that you acknowledged the problem of having different formats in binary search deserve a like. keep up the good work!

  • @HananTariq-ws9wd
    @HananTariq-ws9wd ปีที่แล้ว +17

    Understood!! Hi I'm a Pakistani and I study at US. I really like your DSA playlist and recommend it to everyone. Thank you so much for your effort.

    • @AmanSingh-wr6mj
      @AmanSingh-wr6mj 8 หลายเดือนก่อน +7

      Pucha kisine?

    • @travelbest5623
      @travelbest5623 2 หลายเดือนก่อน +1

      Ab ji*@d recruitment mai bhi dsa poochne lage kya? 😂😂

  • @vishious14
    @vishious14 9 หลายเดือนก่อน +5

    6 minutes into the video, I was able to deduce the whole logic as soon as I understood the approach !!!!!! Amazing content !!!!!!

  • @ayushpatidar5778
    @ayushpatidar5778 ปีที่แล้ว +14

    The way you cover each and every edge case is amazing. Understood everything 👍

  • @shrirambalaji2915
    @shrirambalaji2915 ปีที่แล้ว +3

    just watched like 7 min and understood the solution and what i am missing out
    thanks man you are awesome

  • @surendhar.v4952
    @surendhar.v4952 ปีที่แล้ว +10

    If hurts the most , when you realize this easy question took you more than 2 hour and failed several time while in the test cases below 5 when you submit in leetcode.
    I did a course on java in youtube from a famous youtuber an year ago.
    I took a short break of two months for my semster exam and other activities.
    I can remind that I solved a similar type of question in an year ago.
    But now , I am struggling to do a easy problem like this....
    Taking a break, even it is small gets your mind out of the programming mode.

    • @vaibhavvm4147
      @vaibhavvm4147 10 หลายเดือนก่อน

      bro where did u do dsa in java from?

  • @mehulthuletiya497
    @mehulthuletiya497 ปีที่แล้ว +13

    00:38 Problem statement
    01:21 Brute-force approach
    01:38 Optimal approach
    06:30 Dry-run
    10:35 Pseudocode
    12:57 Code
    13:20 Optimised version : If you want try to do then
    15:04 Code
    15:27 Complexity

  • @bhushanambhore8378
    @bhushanambhore8378 15 วันที่ผ่านมา +1

    I felt proud of myself of solving this question in o(logn) time without even looking this video cz obviously I've seen your previous 2 videos and of course able to solve this one 😎.. Thank you Striver.

  • @abhaymaurya9
    @abhaymaurya9 4 หลายเดือนก่อน +2

    the same exact code i was able to write down without even watching your lecture first , kudos to u🙌❣

  • @harshitgarg2820
    @harshitgarg2820 ปีที่แล้ว +19

    Striver sir plz start a series for strings to simplify strings for us just like you did with the other topics🙏

  • @RagaviSathiyamoorthy
    @RagaviSathiyamoorthy 11 หลายเดือนก่อน +1

    I'm really blessed to watch and learn the concept form you striver and i'm solving the problems now without referring the solutions. Thanks a lot.

  • @iWontFakeIt
    @iWontFakeIt ปีที่แล้ว +13

    man what an explanation ! I saw several solutions on leetcode discuss but couldn't understand all of it, some if else conditions were going above my head, but you made it so clear I did code it myself both leetcode 153 and 154 with AC solutions

  • @snigdhadatta4702
    @snigdhadatta4702 3 หลายเดือนก่อน +1

    I was solving this for the first time , was struggling because everytime was giving me runtime error and guess what i lerally watched the first 10 mins only infinite times , because my dumb brain was just not convincing myself that how is this done, at 3pm night i passed this that too in 0ms time without seeing your written code 😭😭😭😭😭. It was giving me stress because i haven't been able to pass a single solution that day so i really needed anything to get accepted just to boost my morale . Thanks striver.

  • @SahitiDantuluri
    @SahitiDantuluri 4 หลายเดือนก่อน

    I have gone through some solutions to this problem and able to understand but if I try to recollect and code it later I would be a little confused. But your explanation and approach is so detailed and very easy to understand that I am able to solve it on my own without any confusion (even after many days). Thanks a lot!!

  • @parth2439
    @parth2439 8 หลายเดือนก่อน +1

    Understood, the last optimisation was great !!

  • @namangarg8976
    @namangarg8976 ปีที่แล้ว +4

    Another approach I thought of -
    -> If left array is sorted, right is unsorted. Then go to right as pivot point can be current element or in right array
    -> If right is sorted, left is unsorted. Then go to left as pivot point can be current element or in left array
    -> If both are sorted then break and just compare the ans with arr[low] as complete search space is sorted.
    int findMin(vector& arr)
    {
    int low = 0;
    int high = arr.size() - 1;
    int ans = INT_MAX;
    while(low

    • @ompandey2911
      @ompandey2911 9 หลายเดือนก่อน

      Was wondering, What if I search for target = INT_MIN and keep the code same as the previous video wont the arr[low] be my answer?

  • @deepakff7498
    @deepakff7498 6 วันที่ผ่านมา

    you are binary search playlist is goated bro

  • @Cubeone11
    @Cubeone11 2 หลายเดือนก่อน +1

    I used to think that neetcode gives the best explanation, but after watching this playlist i changed my thoughts.

  • @visase2036
    @visase2036 ปีที่แล้ว +1

    Thanks Striver. Adding my thoughts for (duplicates) .
    If we apply the previous logic of high-- or low++ as the mid and low/high values are equal , we will end up getting the minimum element but that does not gaurentee the no of times array has been rotated .
    Examples:
    array=[1,1,2,1,1] ,
    orignal array = [1,1,1,1,2].
    The correct answer is 3 (as the element at 0th index has been moved to 3rd index [1,1,2,1,1]).
    But if we apply the previous logic, the answer would come as 0 as 0th index is the minimum element.
    To upsolve this, we can do the following :
    Keep reducing high, untill [high-1] > [high] (2>1).
    Once you attain this point, high(3rd index) will be the answer.

    • @floatingpoint7629
      @floatingpoint7629 ปีที่แล้ว

      this does not cover all the cases

    • @ayushmittal9666
      @ayushmittal9666 11 หลายเดือนก่อน

      I think if we remove the condition of checking if(a[low]

  • @sukhjattana5887
    @sukhjattana5887 ปีที่แล้ว

    u unfolded the mysterious binary search....thank you!!!

  • @MansiBansalc
    @MansiBansalc 7 หลายเดือนก่อน

    YOU ARE AN AMAZING TEACHER! THANKYOU FOR EXISTING!

  • @RAJSINGH-mr7hq
    @RAJSINGH-mr7hq ปีที่แล้ว +1

    Understood! Awesome explanation as always, thank you soooo much for your effort!!

  • @AyushEditz-hs6pf
    @AyushEditz-hs6pf หลายเดือนก่อน

    This works as well: first check if the right side of mid is sorted then check of left side.
    int findMin(vector& nums) {
    int ans=INT_MAX;
    int low=0;
    int high=nums.size()-1;
    while(low

  • @andycharlie3255
    @andycharlie3255 ปีที่แล้ว

    woow bro, this is crazy, legendary explanation, hats off man

  • @himanshusingh1899
    @himanshusingh1899 2 หลายเดือนก่อน

    Best DSA course on you tube.

  • @Rohitkumar-bx8ne
    @Rohitkumar-bx8ne 5 หลายเดือนก่อน +1

    solved without any help with BS, but before solving i have watched the previous two videos of the playlist which helped in developing the thinking skill for solving this problem

  • @Manasidas99
    @Manasidas99 ปีที่แล้ว

    Understood sir thank you very much, sir. Your teaching style is really amazing. I hope I will crack my interview.

  • @jagdishkhetre4515
    @jagdishkhetre4515 ปีที่แล้ว

    Understood...Awesome Binary search Playlist.. 👏

  • @samlinus836
    @samlinus836 ปีที่แล้ว +4

    I guess this algorithm fails for the below input:
    arr = [3,1,2]
    Your explanation is so clear bro❤
    This condition should be added:
    min = Math.min(min,nums[mid]);

    • @theanimerecaphub
      @theanimerecaphub ปีที่แล้ว +1

      ya you have to save mid as a probable answer and compare it while moving on left

    • @NitinKumar-wm2dg
      @NitinKumar-wm2dg ปีที่แล้ว +3

      change it to nums[low] , you might get your answer, striver's code passes all the testcases

  • @nirajaya5
    @nirajaya5 3 หลายเดือนก่อน

    Great explanation! Thank you so much.

  • @paragroy5359
    @paragroy5359 10 หลายเดือนก่อน

    Thanks a lot for making such videos.
    Your content is amazing.
    Keep on doing the great work

  • @luvdhamija5157
    @luvdhamija5157 10 หลายเดือนก่อน +1

    We know that if it is sorted in nature then arr[low] would always be the minimum number of all. by considering this we can simplify this as following.
    low=0
    high=len(nums)-1
    while lownums[high]:
    low=mid+1
    elif nums[low]>nums[mid]:
    high=mid
    else:
    break
    return nums[low]

  • @UserUser-tn8tv
    @UserUser-tn8tv 9 หลายเดือนก่อน

    Understood. Very Good Explanation

  • @Manishgupta200
    @Manishgupta200 ปีที่แล้ว +1

    Other way to solve this problem is by pivot search..
    Here is the approach,
    if(nums[nums.size()-1] > nums[0]) return nums[0];
    // find pivot
    int s = 0, e = nums.size()-1, mid = s + (e - s) / 2;
    while(s < e){
    if(nums[mid] >= nums[0]){
    s = mid + 1;
    }
    else{
    e = mid;
    }
    mid = s + (e - s) / 2;
    }
    return nums[mid];

  • @shreyanshdasgupta5807
    @shreyanshdasgupta5807 24 วันที่ผ่านมา

    00:04 Find the minimum in a rotated sorted array using binary search.
    02:08 Identify the sorted half in a rotated sorted array
    04:19 The left portion of the rotated sorted array contains the minimum.
    06:37 Identifying and eliminating the minimum element in a rotated sorted array.
    08:40 Finding the smallest element in rotated sorted arrays using binary search.
    11:06 Binary search on a rotated sorted array
    13:13 Optimization in identifying sorted search space
    15:16 Binary search stops in a sorted search space, improving time complexity

  • @anuragparasharsarmah1045
    @anuragparasharsarmah1045 7 หลายเดือนก่อน

    How I thought about this solution is, the minimum is always in the left part of the array in a normal sorted array. However in a rotated sorted array the minimum is always in the unsorted half. So we move to the unsorted right half if it exists. Otherwise we always move to the left.
    while(low

  • @keerthireddy8074
    @keerthireddy8074 ปีที่แล้ว

    I think this below code is simpler and easier to understand:
    int findPivot(vector &nums){
    int low = 0;
    int high = nums.size()-1;
    int pivot =0; // if not rotated, it should return 0
    while (low

  • @sunnykumarpal5087
    @sunnykumarpal5087 ปีที่แล้ว

    Bhaiya your explanation is relay fabulous. It makes hard concepts easily understandable to us. Thank you bhaiya for helping us in dsa.

  • @akkipinky9194
    @akkipinky9194 7 หลายเดือนก่อน

    Thanks for the incredible knowledge u give us...understood!!

  • @kiranmoura2974
    @kiranmoura2974 ปีที่แล้ว +12

    For duplicates
    I think the whole code will remain same only the optimized part will be changed as if (a[low]==a[mid] and a[low]==a[high])
    {ans=min(ans,arr[low]);
    Low++;
    High--;
    Continue;
    Please check whether it is correct or not .

    • @anshuman-sl9du
      @anshuman-sl9du ปีที่แล้ว +3

      yeah its correct dude !! thanx i was stuck there 🤖

    • @omkarshendge5438
      @omkarshendge5438 3 หลายเดือนก่อน

      yea you are right so basically the duplicates case arises when there is like mid low high all three are same so basically this case is same as search in a rotated sorted array 2 right? there also this case has rose.

  • @Aks-47
    @Aks-47 9 หลายเดือนก่อน +1

    slightly lengthier, but core logic is , we need to handle 2 cases where we are uncertain where to move, that was the crux for me, a) mid is less than lo and hi, b) mid greater than lo and hi, if we exclude that , then searching is regular BS,
    attaching java code for the same
    int ans = Integer.MAX_VALUE;
    while(lo

  • @Anshydv3
    @Anshydv3 ปีที่แล้ว

    understood ! the best explanation bhaiya , you are hero and a real gem❤

  • @baibhavghimire3827
    @baibhavghimire3827 8 หลายเดือนก่อน

    You beat neetcode on this🎉. Superb dude.

  • @rahulsidhu5945
    @rahulsidhu5945 ปีที่แล้ว

    Understood.. Awesome Binary search Playlist..😍

  • @RishabhKumar0094
    @RishabhKumar0094 3 หลายเดือนก่อน

    understood, for duplicate elements worst case time complexity will be O(n/2).

    • @harishms5330
      @harishms5330 2 หลายเดือนก่อน +1

      how

    • @RishabhKumar0094
      @RishabhKumar0094 2 หลายเดือนก่อน

      @@harishms5330 So consider an example arr=11111111111111 size=14 it will take about O(7),
      if arr[low]==arr[mid]==arr[high] low++; high--; till low crosses high, it will follow the condition , at one time, low increases to 1 and high decreases to 1, so arr size reduced by 2 similarly it will go till O(n/2).

    • @harishms5330
      @harishms5330 2 หลายเดือนก่อน

      @@RishabhKumar0094 thank u🫡

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 ปีที่แล้ว

    Good explanation. Explanation in depth

  • @kingbadshah452
    @kingbadshah452 8 หลายเดือนก่อน

    thanks striver understood everything

  • @tanishkthakur9965
    @tanishkthakur9965 5 หลายเดือนก่อน +1

    got it , understood everything

  • @aishezsingh7004
    @aishezsingh7004 3 หลายเดือนก่อน

    I think This is more intutive moving towards unsorted and if sorted move left
    while(low arr[mid] )
    high = mid - 1;
    else if( arr[mid] > arr[high] )
    low = mid + 1;
    else
    {
    ans = min(ans , arr[low] );
    break;
    }
    }
    return ans;

  • @aliakbaransaria3-925
    @aliakbaransaria3-925 ปีที่แล้ว

    Very good explanation
    Thank you

  • @RagaviSathiyamoorthy
    @RagaviSathiyamoorthy 11 หลายเดือนก่อน

    Sir completed the problem which you gave as homework 😇😇

  • @dipingrover1970
    @dipingrover1970 5 หลายเดือนก่อน

    amazing explanation . thanks a lot

  • @thefourhourtalk
    @thefourhourtalk 4 หลายเดือนก่อน +1

    a random tip : if you dont understand this (because at first I didn't get it ) take your pen and paper and dry run the example of 45123

  • @motivationalcomred
    @motivationalcomred ปีที่แล้ว

    @striver take case a = [5[L] 1 2[M] 3 4[H]] mid is lesser in both arrays 2

  • @hariomtiwari9283
    @hariomtiwari9283 ปีที่แล้ว +1

    Super Explanation 🎉🎉

  • @riteshsrivastava3447
    @riteshsrivastava3447 ปีที่แล้ว

    Solution based on applying binary search on sorted side and storing start index element as possible solution : tops 100% in leetcode
    int findMin(vector& nums) {
    int ans=INT_MAX;
    int start=0;
    int end=nums.size()-1;
    // logic is to find sorted side and store start index value into min each time
    while(start

  • @aps2129
    @aps2129 3 หลายเดือนก่อน

    Amazing explanation!!!!!

  • @piyushroy3278
    @piyushroy3278 4 หลายเดือนก่อน

    understood sir. Huge kudos to you :)

  • @neerajkumar-ts6om
    @neerajkumar-ts6om 18 วันที่ผ่านมา

    You don't know how relived I am to know that you won't change format, I was afraid that it is some advance technique. I always hated binary search, hope I wouldn't after this your Binary Search Playlist

  • @RolexGTA
    @RolexGTA 10 หลายเดือนก่อน +1

    i am learn from you , one day i will cross you 🙇

  • @venkynani9892
    @venkynani9892 11 หลายเดือนก่อน

    My thought process:
    int low=0;
    int high=arr.length-1;
    int min=arr[high];
    while(lowmin)
    {
    low=mid+1;
    }
    else{
    min=arr[mid];
    high=mid-1;
    }
    }
    return min;

  • @debapriyachandra1767
    @debapriyachandra1767 ปีที่แล้ว

    Can also be done by finding pivot.
    class Solution {
    public:
    int findMin(vector& nums) {
    int n=nums.size();
    int left=0,right=n-1;
    while(right >= left){
    int mid=(left+right)>>1;
    int val=nums[mid];
    int prev=1e9;
    int next=1e9;
    if(mid-1>=0)prev=nums[mid-1];
    if(mid+1 val && next > val)return val;
    if(val >= nums[left] && val >= nums[right]){
    left=mid+1;
    }
    else right=mid-1;
    }
    return -1;
    }
    };

  • @sayak4636
    @sayak4636 ปีที่แล้ว +9

    Hometask(LC-154):-
    class Solution {
    public:
    int findMin(vector& nums) {
    int s=0;
    int e=nums.size()-1;int ans=INT_MAX;
    while(s

    • @floatingpoint7629
      @floatingpoint7629 ปีที่แล้ว

      if interviewers ask you to modify it so it returns the index, this won't work

    • @6mahine_mein_google
      @6mahine_mein_google ปีที่แล้ว

      @@floatingpoint7629 In duplicates we cant return index because it would have no meaning
      consider [3,3,3,3,3] this as example, minimum here is 3 but index is not defined because index can be anything here. Please correct me if i am wrong

    • @floatingpoint7629
      @floatingpoint7629 ปีที่แล้ว

      @@6mahine_mein_google if all are duplicates then array is not a rotated one. it is guaranteed that array is at least rotated once

  • @make4u982
    @make4u982 20 วันที่ผ่านมา

    understood good job bro

  • @saiyyamagrawal765
    @saiyyamagrawal765 หลายเดือนก่อน

    int findMin(vector& nums) {
    int n = nums.size();
    int low = 0 , high=n-1;
    while(low

  • @kiranmoura2974
    @kiranmoura2974 ปีที่แล้ว

    Bahut ache se smgh aaya sir ❤

  • @Shunya_Advait
    @Shunya_Advait ปีที่แล้ว

    Understood Sir. Thank You Sir 👌👌

  • @ddevarapaga5134
    @ddevarapaga5134 3 หลายเดือนก่อน

    Understood perfect bro

  • @NitinKumar-wm2dg
    @NitinKumar-wm2dg ปีที่แล้ว

    understood, thank you bhaiya

  • @hengulrajsaikia9227
    @hengulrajsaikia9227 2 หลายเดือนก่อน

    The mid will point to the minimum element at least once

  • @secondarypemail7181
    @secondarypemail7181 ปีที่แล้ว

    To find minimum element in rotated sorted aray with duplicates,just add the condition used before while finding an element in rotated sorted array with duplicates and the solution works fine.

  • @subhamraul
    @subhamraul 4 หลายเดือนก่อน

    I actually thought the same idea by myself 😁

  • @AnmolGupta-oj4lm
    @AnmolGupta-oj4lm ปีที่แล้ว

    Understood Very Well!

  • @JothiprakashThangaraj
    @JothiprakashThangaraj 3 หลายเดือนก่อน

    understood, thanks a lot!

  • @dank7044
    @dank7044 11 หลายเดือนก่อน

    did this on my own in one go.

  • @presidenttalks8
    @presidenttalks8 8 หลายเดือนก่อน

    Understood👍 thank you sir

  • @samratsamrat8477
    @samratsamrat8477 22 วันที่ผ่านมา

    I first like💓💓 it then watch it because I know it is the best.😎😎

  • @TrinmoyDutta
    @TrinmoyDutta 7 หลายเดือนก่อน

    while(low

  • @md_seraj786_
    @md_seraj786_ 7 หลายเดือนก่อน

    understood all clear ❤

  • @NazeerBashaShaik
    @NazeerBashaShaik 6 หลายเดือนก่อน

    Understood, thank you.

  • @samuelfrank1369
    @samuelfrank1369 ปีที่แล้ว

    Understood, Thanks a lot

  • @per.seus._
    @per.seus._ ปีที่แล้ว +1

    UNDERSTOOD❤

  • @rushidesai2836
    @rushidesai2836 5 หลายเดือนก่อน

    Great question!

  • @rahulkumarjena8252
    @rahulkumarjena8252 7 หลายเดือนก่อน

    @takeUForward , can you also add find pivot element in Sorted Roatated array .i am unable to find it out in your playlist

  • @atharva_g_vlogs
    @atharva_g_vlogs หลายเดือนก่อน +1

    UNDERSTOOD

  • @bilal_khan8514
    @bilal_khan8514 8 หลายเดือนก่อน

    Understood Bhaiya 😃

  • @TusharSonwane-c3d
    @TusharSonwane-c3d ปีที่แล้ว

    Understood everything

  • @abhaythakur2597
    @abhaythakur2597 ปีที่แล้ว

    very well explained

  • @infernogamer52
    @infernogamer52 ปีที่แล้ว

    Understood Bhaiya!

  • @yossihadad8558
    @yossihadad8558 10 หลายเดือนก่อน +1

    amazing!

  • @mahadishakkhor123
    @mahadishakkhor123 7 หลายเดือนก่อน

    Hey god bless you bro❤

  • @myproject6768
    @myproject6768 ปีที่แล้ว

    Absolutely understand ❤

  • @AdityaKumar-eb9ff
    @AdityaKumar-eb9ff ปีที่แล้ว

    nice explanation

  • @ganjinaveen7338
    @ganjinaveen7338 ปีที่แล้ว

    Super level understood

  • @NetajiSaiSuru
    @NetajiSaiSuru 2 หลายเดือนก่อน +1

    What is the elements in the array are not unique let array ={5,4,1,2,2,2,2,2} then what should be the approach

    • @MohammadEhshan-ve6uz
      @MohammadEhshan-ve6uz 2 หลายเดือนก่อน

      question is wrong if the array is rotated 4 cannot come after 5 as it is smaller than 5

  • @harishnaik8164
    @harishnaik8164 ปีที่แล้ว +1

    i think below code is easier
    class Solution {
    public:
    int findMin(vector& nums) {
    int n = nums.size();
    int low=0, high=n-1;
    while(low nums[high])
    low=mid+1;
    }
    return -1;
    }
    };

  • @lakshgangwani3014
    @lakshgangwani3014 ปีที่แล้ว +1

    if my array is [2, 4, 1, 2], In this case wouldn't the optimised code would give the answer 2 (because of the if condition (ar[low]

    • @kc9049
      @kc9049 ปีที่แล้ว +3

      your array has a duplicate element, and the code is for the unique element.