Given a package label, reverse each group of 3 characters. If a group has less than 3 characters, reverse the entire label. If the label length is a multiple of 3, the last group should also be in reverse.
Explanation: Step-by-step: 1. Split the input string into groups of 3 characters: ['abc', 'def']. 2. Reverse each group: ['cba', 'fed']. 3. Concatenate the reversed groups: 'fedcba'.
Explanation: Step-by-step: 1. Split the input string into groups of 3 characters: ['abc', 'def', 'ghi', 'cde']. 2. Reverse each group: ['cba', 'fed', 'ihg', 'dec']. 3. Since the last group 'cde' has less than 3 characters, reverse the entire label: 'dcba'.
Master coding challenges related to Strings and solve the [Backup] Package Label Generator problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak