Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Solution: Largest Palindromic Number

Problem Statement

Given a string s containing 0 to 9 digits, create the largest possible palindromic number using the string characters. It should not contain leading zeroes.

A palindromic number reads the same backward as forward.

If it's not possible to form such a number using all digits of the given string, you can skip some of them.

Examples

    • Input: "323211444"
    • Expected Output: "432141234"
    • Justification: This is the largest palindromic number that can be formed from the given digits.
    • Input: "998877"

.....

.....

.....

Like the course? Get enrolled and start learning!