Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

Leetcode 704. Binary Search| Hindi | Python | Leetcode | Optimized way

Автор: DataEngineering360

Загружено: 2025-12-07

Просмотров: 7

Описание:

#leetcode #python #timecomplexity
Q. Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.

You must write an algorithm with O(log n) runtime complexity.



Example 1:

Input: nums = [-1,0,3,5,9,12], target = 9
Output: 4
Explanation: 9 exists in nums and its index is 4

Solution -
Optimized way - Note - this is sample code.. we cannot use angle brackets in description, so I removed them from the code.

class Solution:
def search(self, nums: List[int], target: int) - int:
l,r = 0, len(nums)-1

while l=r:
mid = (l+r)//2
if target == nums[mid]:
return mid
elif target nums[mid]:
r = mid - 1
else:
l = mid + 1
return -1

#python #leetcodesolutions #dsa #pythoninterviewquestions

Python Developer Interview Questions Answers
Top 10 Python Developer Interview Questions Answer
Mostly asked Python Developer Interview Questions Answer
Commonly asked Python Developer Interview Questions Answer



Tags -
Python leetcode problems
leetcode two sum
leetcode solutions
leetcode hindi
two sum python
two sum problem

Leetcode 704. Binary Search| Hindi | Python | Leetcode | Optimized way

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Нужен ли университет в эпоху ИИ. Стоит ли сейчас тратить 5 лет на университет?

Нужен ли университет в эпоху ИИ. Стоит ли сейчас тратить 5 лет на университет?

Leetcode 35. Search Insert Position | Hindi | Python | Leetcode | Optimized way

Leetcode 35. Search Insert Position | Hindi | Python | Leetcode | Optimized way

Leetcode 35 | Search Insert Position | Easy | Binary Search method

Leetcode 35 | Search Insert Position | Easy | Binary Search method

Leetcode 14. Longest Common Prefix | Hindii | Python | Leetcode 14 | Optimized way | Interview

Leetcode 14. Longest Common Prefix | Hindii | Python | Leetcode 14 | Optimized way | Interview

Learn Python FAST for Beginners 🚀#coding #conditionals #loops #functions

Learn Python FAST for Beginners 🚀#coding #conditionals #loops #functions

LeetCode 3803 & 3804 Explained | Count Residue Prefixes & Centered Subarrays | Easy Solutions

LeetCode 3803 & 3804 Explained | Count Residue Prefixes & Centered Subarrays | Easy Solutions

it only took 2 characters

it only took 2 characters

Valid Anagram Explained from First Principles | 7 Core Intuitions & 6 Interview Approaches | Java

Valid Anagram Explained from First Principles | 7 Core Intuitions & 6 Interview Approaches | Java

99% женщин делают ЭТО, а мужчины продолжают выдавать свои секреты #отношения #психология

99% женщин делают ЭТО, а мужчины продолжают выдавать свои секреты #отношения #психология

Informacje Telewizja Republika 23.01.2026 godzina 12:30

Informacje Telewizja Republika 23.01.2026 godzina 12:30

MIŁOSZ LODOWSKI | JAN POSPIESZALSKI ROZMAWIA #181

MIŁOSZ LODOWSKI | JAN POSPIESZALSKI ROZMAWIA #181

Anna Bryłka: Komisja Europejska działa bezkarnie. Rozmowa Wikły

Anna Bryłka: Komisja Europejska działa bezkarnie. Rozmowa Wikły

Trump w Davos: wielka rozbiórka świata

Trump w Davos: wielka rozbiórka świata

Policja znowu mnie zatrzymała i chciała ukarać! Batalia w radomskich sądach no i jest wyrok! #289

Policja znowu mnie zatrzymała i chciała ukarać! Batalia w radomskich sądach no i jest wyrok! #289

Ścigają Mateckiego i Wosia. „Zbrodnią” było pokazanie siłowego przejęcia KRS | A. Klarenbach

Ścigają Mateckiego i Wosia. „Zbrodnią” było pokazanie siłowego przejęcia KRS | A. Klarenbach

House Robber - Leetcode 198 - Python Dynamic Programming

House Robber - Leetcode 198 - Python Dynamic Programming

Leetcode 739. Daily Temperatures | Hindi | Python | Leetcode | Optimized way

Leetcode 739. Daily Temperatures | Hindi | Python | Leetcode | Optimized way

Binary Search Explained 🔍 | Find Target Index (DSA Foundation)

Binary Search Explained 🔍 | Find Target Index (DSA Foundation)

LeetCode 258 (Add Digits) | Must-Know Easy Problem for Interviews

LeetCode 258 (Add Digits) | Must-Know Easy Problem for Interviews

Contains Duplicate | 4 Approaches + 5 Key Insights | ThinkDSA Series | LeetCode Explained

Contains Duplicate | 4 Approaches + 5 Key Insights | ThinkDSA Series | LeetCode Explained

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com