Amazon Coding Question – Solved

9 Live
Company's software team utilizes several algorithms to maintain data integrity, one of which targets the encoding of symmetrical names. Symmetrical names are unique in that they read identically in both directions, similar to palindromes in language parlance. The chief aim of the algorithm is to rearrange the characters in the original symmetrical name according to these criteria: - The rearranged name is a reshuffled version of the original symmetrical name. - The restructured name should be symmetrical as well. - This restructured name should be lexicographically smallest among all its symmetric permutations. Given an initial symmetrical name that contains only lowercase English characters, compute the encoded name. A string s is considered to be lexicographically smaller than the string t of the same length if the first character in s that differs from that in t is smaller, For example, "abcd" is lexicographically smaller than "abdc" but larger than "abad" Note that the output encoded name could match the original name if it's already the smallest lexicographically. Example The original string is letters = "babab". This can be reversed to give "abbba", which is a symmetric rearrangement of the original symmetrical name and is the smallest possible reverse order, It satisfies all the requirements so return the string abbba.

Asked in: Amazon

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| The supply chain manager at one of Amazon's warehouses is shipping the last con… |
| Determine the highest value after executing n steps on an infinite 2D grid that… |
| Amazon Prime Video is developing a new feature called "Segmentify." This featur… |
| In this new stock prediction game launched on Amazon Games, Player 1 provides P… |
| Amazon operates numerous warehouses, with each warehouse holding inventory[i] u… |
| In Amazon's highly efficient logistics network, minimizing operational overhead… |