Tap here to switch tabs
Problem
Submissions

Problem: Sort the Jumbled Numbers

med
30 min
Try to solve the Sort the Jumbled Numbers problem.

Statement

You are given a 00 indexed integer array mapping of length 1010 that defines a mapping rule for digits from 00 to 99, where mapping[i] = j means that the digit ii is replaced by the digit jj.

The mapped value of an integer is formed by replacing each of its digits with its mapped equivalent according to mapping. Leading zeros in the resulting mapped integer are ignored when evaluating its numerical value, though a mapped value of zero is treated as 00.

You are also given an integer array nums. Sort the array nums in non decreasing order according to the mapped values of its elements and return the sorted array.

Note: If two elements have the same mapped value, they must preserve their original relative order from nums.

Constraints:

  • mapping.length =10= 10

  • 0≤0 \leq mapping[i] ≤9\leq 9

  • All the values of mapping[i] are unique.

  • 1≤1 \leq nums.length ≤3imes104\leq 3 imes 10^4

  • 0≤0 \leq nums[i] <109< 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sort the Jumbled Numbers

med
30 min
Try to solve the Sort the Jumbled Numbers problem.

Statement

You are given a 00 indexed integer array mapping of length 1010 that defines a mapping rule for digits from 00 to 99, where mapping[i] = j means that the digit ii is replaced by the digit jj.

The mapped value of an integer is formed by replacing each of its digits with its mapped equivalent according to mapping. Leading zeros in the resulting mapped integer are ignored when evaluating its numerical value, though a mapped value of zero is treated as 00.

You are also given an integer array nums. Sort the array nums in non decreasing order according to the mapped values of its elements and return the sorted array.

Note: If two elements have the same mapped value, they must preserve their original relative order from nums.

Constraints:

  • mapping.length =10= 10

  • 0≤0 \leq mapping[i] ≤9\leq 9

  • All the values of mapping[i] are unique.

  • 1≤1 \leq nums.length ≤3imes104\leq 3 imes 10^4

  • 0≤0 \leq nums[i] <109< 10^9