2089. Find Target Indices After Sorting Array Easy
1/**
2 * [2089] Find Target Indices After Sorting Array
3 *
4 * You are given a 0-indexed integer array nums and a target element target.
5 * A target index is an index i such that nums[i] == target.
6 * Return a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order.
7 *
8 * Example 1:
9 *
10 * Input: nums = [1,2,5,2,3], target = 2
11 * Output: [1,2]
12 * Explanation: After sorting, nums is [1,<u>2</u>,<u>2</u>,3,5].
13 * The indices where nums[i] == 2 are 1 and 2.
14 *
15 * Example 2:
16 *
17 * Input: nums = [1,2,5,2,3], target = 3
18 * Output: [3]
19 * Explanation: After sorting, nums is [1,2,2,<u>3</u>,5].
20 * The index where nums[i] == 3 is 3.
21 *
22 * Example 3:
23 *
24 * Input: nums = [1,2,5,2,3], target = 5
25 * Output: [4]
26 * Explanation: After sorting, nums is [1,2,2,3,<u>5</u>].
27 * The index where nums[i] == 5 is 4.
28 *
29 *
30 * Constraints:
31 *
32 * 1 <= nums.length <= 100
33 * 1 <= nums[i], target <= 100
34 *
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/find-target-indices-after-sorting-array/
39// discuss: https://leetcode.com/problems/find-target-indices-after-sorting-array/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44 pub fn target_indices(nums: Vec<i32>, target: i32) -> Vec<i32> {
45 vec![]
46 }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53 use super::*;
54
55 #[test]
56 fn test_2089() {
57 }
58}
59
Back
© 2025 bowen.ge All Rights Reserved.