Find First and Last Position of Element in Sorted Array Leetcode 34 Solution | Searching and Sorting
Vložit
- čas přidán 14. 05. 2021
- Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. Question Statement:
1. Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.
2. If target is not found in the array, return [-1, -1].
3. You must write an algorithm with O(log n) runtime complexity.
Topic: #BinarySearch #SearchingAndSorting
Used #DataStructure: #Array
#TimeComplexity: O(log n)
#SpaceComplexity: O(1)
---------------------------------------------------------------
For detailed information and other exercises, VISIT: www.pepcoding.com
Have a look at our result: www.pepcoding.com/placements
Follow us on our FB page: / pepcoding
Follow us on Instagram: / pepcoding
Follow us on LinkedIn: / pepcoding-education
----------------------------------------------------------------
#BinarySearch #Leetcode34 #SearchingAndSorting
Best video on you tube
I watched almost 5 6 video of the same question but belive me this was something that is easy understandable
Thanks
Glad you liked it!
Keep learning.
And for better experience, visit nados.io, where you will get well curated content and career opportunities.
best explaination literally! I have watched several videos then i stopped here
she is the best teacher of pepcoding
Such an easy explanation thank you so much
The only tutorial on this problem I understood. Thanks!
you have best way to explain....lit best
Best explanation, I came across.
Loved the explanation!! One of the best on CZcams!!
THANK YOU
I don't understand Indian but your code explained everything to me. Very classic approach and super optimal. Thanks!
Awesome explaination....thank u ma'am !!!
This is the best ever explanation. Thanks a lot for such a great explanation.
easy explanation ma'am thanku
exceeding the time limit at leetcode
boht hi mast samjahya maam apne ,super clear ho gya binary search
Do check out more such content on nados.pepcoding.com
You just did a Magic in one minute. Great.
Very clear explanation ,Manisha Mam🙏
Thanks a lot 😊 and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms
mam great explanation btw congo for 45k
Thanks a lot 😊 keep motivating, keep learning and keep loving Pepcoding😊
The best explanation for this question, very very simple solution with minor changes, thanks for making understand the concept so clearly. Liked and subscribed pepcoding for this.
time limit is also exceeding at gfg
Thank you for taking so much of initiative 👍👍👍🤗🤗
Nice explanation!!
For more content like this use nados.pepcoding.com
Crazy solution, very simple :) (y)
WOW
nice approach:)
Glad you liked it!
Keep learning.
And for better experience, visit nados.io, where you will get well curated content and career opportunities.
Python code:
class Solution:
def searchRange(self, nums: List[int], target: int) -> List[int]:
ans = [-1, -1]
lo = 0; hi = len(nums)-1
while lo
whai if array is not shorted
3:54 par aapne last index ko 2 se update kiya hai wahan par 6 se karna hai update