An icon font names its glyphs with short lowercase codes. Two codes are "shifted" versions of each other if they have the same length and you can turn one into the other by moving every letter forward the same number of places in the alphabet, wrapping from z back to a. For example, "ace" shifted by 1 is "bdf", and "yza" shifted by 2 is "abc".
Write groupShifted(codes) that groups codes that are shifted versions of each other. Return the groups in the order their first code appears, with codes inside a group in their original order.
Input: codes = ["ace","bdf","yac","ab","za","q","hello"] Output: [["ace","bdf","yac"],["ab","za"],["q"],["hello"]]
In ace, bdf, and yac, each letter is 2 places after the one before it (wrapping for yac). ab and za both step by 1.
Input: codes = ["abc"] Output: [["abc"]]
One code is a group of one.
0 <= codes.length <= 10^40 <= codes[i].length <= 50Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #35 Group Shifted Icon Codes. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.