filmov
tv
Binary Search in Python: Find Closest Number
Показать описание
In this video, we will be given a sorted array and a target number. Our goal is to find a number in the array that is closest to the target number. We will be making use of binary search to solve this problem.
The array may contain duplicate values and negative numbers.
Example 1:
Input : arr[] = {1, 2, 4, 5, 6, 6, 8, 9}
Target number = 11
Output : 9
9 is closest to 11 in given array
Example 2:
Input :arr[] = {2, 5, 6, 7, 8, 8, 9};
Target number = 4
Output : 5
This video is one part of the Binary Search playlist on my channel. For more videos on binary search and how to apply it to various problems, check out the other videos:
The software written in this video is available at:
Do you like the development environment I'm using in this video? It's a customized version of vim that's enhanced for Python development. If you want to see how I set up my vim, I have a series on this here:
If you've found this video helpful and want to stay up-to-date with the latest videos posted on this channel, please subscribe:
The array may contain duplicate values and negative numbers.
Example 1:
Input : arr[] = {1, 2, 4, 5, 6, 6, 8, 9}
Target number = 11
Output : 9
9 is closest to 11 in given array
Example 2:
Input :arr[] = {2, 5, 6, 7, 8, 8, 9};
Target number = 4
Output : 5
This video is one part of the Binary Search playlist on my channel. For more videos on binary search and how to apply it to various problems, check out the other videos:
The software written in this video is available at:
Do you like the development environment I'm using in this video? It's a customized version of vim that's enhanced for Python development. If you want to see how I set up my vim, I have a series on this here:
If you've found this video helpful and want to stay up-to-date with the latest videos posted on this channel, please subscribe:
Комментарии