2089. Find Target Indices After Sorting Array
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 77% Topics: Array, Binary Search, Sorting
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(1)
class Solution(object):
def targetIndices(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
less = sum(x < target for x in nums)
return range(less, less+sum(x == target for x in nums))
Solution from kamyu104/LeetCode-Solutions · MIT