All Posts

Leetcode 33: Search in Rotated Sorted Array

You are given a sorted array ’nums’ which may have been rotated at an unknown pivot. Your task is to search for a target value in this rotated array. Return the index of the target if found, or -1 if not found. The solution must have a runtime complexity of O(log n).

Leetcode 34: Find First and Last Position of Element in Sorted Array

Given a sorted array ’nums’ in non-decreasing order, find the starting and ending index of a target value. If the target is not found, return [-1, -1]. Your solution must run in O(log n) time complexity.

Leetcode 35: Search Insert Position

Given a sorted array of distinct integers and a target value, return the index of the target if it is present. If the target is not in the array, return the index where it should be inserted to maintain the sorted order.

Leetcode 74: Search a 2D Matrix

You are given an m x n matrix where each row is sorted in non-decreasing order, and the first integer of each row is greater than the last integer of the previous row. Given a target integer, return true if the target exists in the matrix or false otherwise. The solution must have a time complexity of O(log(m * n)).

Leetcode 81: Search in Rotated Sorted Array II

You are given a sorted integer array nums that has been rotated at an unknown pivot index k. The array may contain duplicates. Your task is to determine whether a given target exists in the array, minimizing the number of operations as much as possible.

Leetcode 153: Find Minimum in Rotated Sorted Array

Given a sorted array of unique elements, rotated between 1 and n times, find the minimum element in this array.