Binary Search: Pivot Element in Sorted Rotated Array

https://online.codingblocks.com/player/26384/content/7379/80

The code in the video fails this test case: {4,4,4,4,4,4,4,4,4,4,4,4,4,1,2,3}. This is because here a[mid]==a[s] but the right part of array is unsorted not the left part. The code considers left part to be unsorted when the two are equal. please provide the rectified solution.