https://leetcode.com/problems/find-target-indices-after-sorting-array/description/
Find Target Indices After Sorting Array - LeetCode
Find Target Indices After Sorting Array - You are given a 0-indexed integer array nums and a target element target. A target index is an index i such that nums[i] == target. Return a list of the target indices of nums after sorting nums in non-decreasing o
leetcode.com
/**
* @param {number[]} nums
* @param {number} target
* @return {number[]}
*/
var targetIndices = function(nums, target) {
let answer = [];
nums.sort((a, b) => a - b).forEach((element, index) => {
if (target === element)
answer.push(index);
});
return answer;
};
GitHub : https://github.com/developeSHG/LeetCode/tree/main/2089-find-target-indices-after-sorting-array
GitHub - developeSHG/Algorithm-LeetCode: 릿코드 소스코드
릿코드 소스코드. Contribute to developeSHG/Algorithm-LeetCode development by creating an account on GitHub.
github.com
'Coding Test > LeetCode' 카테고리의 다른 글
[LeetCode] (Trees) Lv Easy. Maximum Depth of Binary Tree (0) | 2023.01.21 |
---|---|
[LeetCode] (Linked List) Lv Easy. Delete Node in a Linked List (0) | 2023.01.16 |
[LeetCode] (Strings) Lv Easy. Reverse Integer (0) | 2023.01.16 |
[LeetCode] (Array) Lv Easy. Best Time to Buy and Sell Stock II (0) | 2023.01.16 |
[LeetCode] (Array) Lv Easy. Remove Duplicates from Sorted Array (0) | 2023.01.14 |
댓글