Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Largest Palindromic Number (Medium)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

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

Example 1

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

Example 2

  • Input: s = "998877"

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible