ME

Live Q&A

Closed
19 JUN
GU
Guest11:31 pmHi
GU
Guest11:51 pmwhat is going on here ?
20 JUN
Admin (Host)12:20 amwho are you?
GU
Guest11:38 pmhello
21 JUN
GU
Guest09:36 amHi, I'm new here. What is this session about?
24 JUN
GU
Guest02:06 amhi
25 JUN
GU
Guest12:09 amupperbound + lowerboound
GU
Guest12:09 amneither
GU
Guest12:09 amlowerbound gives lowest index and upperbound-1 gives last index
GU
Guest12:28 amhy
Session EndedChat is closed.
ENDED
👁 0
Queue

Live Problems

2 Items
Submitted by GuestSolved

Find First and Last Position of Element in Sorted Array

Given an array of integers nums and an integer target, return the indices of the first and last occurrence of target in nums. If target is not found in nums, return [-1, -1].

Examples

Example 1:

Input:nums = [5,7,7,8,8,10], target = 8
Output:[3,4]

Example 2:

Input:nums = [5,7,7,8,8,10], target = 6
Output:[-1,-1]

Example 3:

Input:nums = [5,7,7,8,8,10], target = 5
Output:[0,0]

Constraints

  • 0 <= nums.length <= 105
  • -109 <= nums[i] <= 109
  • nums is a non-empty array containing only distinct values
  • -109 <= target <= 109
q1_solved.cpp
q2_solved.cpp
Loading...
Host uploads the public C++ solution

Microsoft OA

ENDED
0 watching