Loading
Loading
Two inventory labels are considered equivalent if one is a rearrangement of the other — the same characters, the same number of times, in any order.
Return whether the two labels are rearrangements of each other.
a = "listen", b = "silent"count al:1 i:1 s:1 t:1 e:1 n:1subtract bevery counter returns to zeroall zerorearrangement confirmedtrueSign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(n) time · O(1) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
Example 2
Different letters entirely.
Example 3
Same letters, different counts.