Find Target Indices After Sorting Array

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
class Solution:
    def targetIndices(self, nums, target):
        count = 0
        lessthan = 0
        for n in nums:
            if n == target:
                count += 1
            if n < target:
                lessthan += 1

        result = []
        for i in range(count):
            result.append(lessthan)
            lessthan += 1

        return result