// https://leetcode.com/problems/search-insert-position/
public class Solution {
public int SearchInsert(int[] nums, int target) {
int l = 0;
int r = nums.Length - 1;
while (l <= r) {
int mid = (l + r) / 2;
if (target < nums[mid])
r = mid - 1;
else if (target > nums[mid])
l = mid + 1;
else return mid;
}
return l;
}
}
-
MY PROJECTS
-
Recent Posts
- Java.Collections.What is the difference between java.util.Collection and java.util.Collections?
- Java.Collections.
- Java.Collections.Arrange the following interfaces in a hierarchy: List, Set, Map, SortedSet, SortedMap, Collection, Iterable, Iterator, NavigableSet, NavigableMap.
- Java.Collections.Why do i need insertion order and what is difference to sortedOrder ?
- Java.What is LinkedHashSet ?
- Java.Collections.What is SortedSet ?
- Java.Collections.Arrange the following interfaces in a hierarchy: List, Set, Map, SortedSet, SortedMap,
- Java.Collections.Name the main JCF interfaces and their implementations.
- Java.Collections.What is a “collection”?
- Java.Algo.1442. Count Triplets That Can Form Two Arrays of Equal XOR
- Java.Core.What is “internationalization”, “localization” in Java ?
- Java.Core.What are generics?
- Java.Core.Suppose there is a method that can throw IOException and FileNotFoundException, in what order should the catch blocks go? How many catch blocks will be executed?
- Java.Core.Can the main method throw an exception outside and if so, where will this exception be handled?
- Java.Core.Is the finally block always executed?
- Java.Core.Can one catch block catch several exceptions at once?
- Java.Core.Is it possible to use a try-finally block (without catch)?
- Java.Core.What is the try-with-resources mechanism?
- Java.Core.Describe the operation of the try-catch-finally block.
- Java.What do you know about OutOfMemoryError?
Categories
- Aptana
- Azure
- C#
- DataSnap
- DBExpress
- Delphi
- Delphi и сети
- Delphi. Язык программирования
- ExtJS
- FastReport
- FireDAC
- FireMonkey
- GIT
- ICS
- IDE
- IIS
- Indy
- InnoSetup
- javascript
- jQuery
- JSON
- LiveBindings
- MSHTML
- MySQL
- PHP
- REST
- Ribbons
- SMS
- SQL инструкции
- SVN
- TRichView
- UniGui
- WebBroker
- WinAPI
- Windows
- Алгоритмы
- Без рубрики
- Деревья
- Ищу ответ
- Компонентостроение
- Мои компоненты
- Начальный уровень
- Обработка исключений
- Парсинг
- Потоки(Threads)
- Регулярные выражения
- Тестирование приложений