Maximum Number from Linked List Problem Statement

Given a linked list where each node contains a single digit, your task is to construct the largest possible number using these digits.

Objective:

Print the maximum integer that can be formed from the given list of digits.

Input:

The first and only line of each test case consists of linked list elements of length n (separated by space and terminated by -1).

Output:

The maximum number that can be formed using the digits present in the linked list.

Example:

Input:
3 1 4 -1
Output:
431

Constraints:

  • 1 <= N <= 106
  • 0 <= data <= 9
  • Time Limit: 1 second

Note:

You do not need to print anything; it has already been taken care of. Just implement the given function.

Follow-Up:

Can you solve this problem in O(N) time and constant space?
AnswerBot
4mo

To find the maximum number that can be formed using the digits present in a linked list.

  • Traverse the linked list and store the digits in an array

  • Sort the array in descending order

  • Concatenate the sorte...read more

Help your peers!
Select
Add answer anonymously...

DE Shaw Software Developer interview questions & answers

A Software Developer was asked 12mo agoQ. Given a binary tree and a target node, burn the tree starting from the target no...read more
A Software Developer was asked Q. What is the purpose of Normalization?
A Software Developer was asked Q. What is the difference between a default constructor and a copy constructor?

Popular interview questions of Software Developer

A Software Developer was asked 12mo agoQ1. Given a binary tree and a target node, burn the tree starting from the target no...read more
A Software Developer was asked Q2. What is the purpose of Normalization?
A Software Developer was asked Q3. What is the difference between a default constructor and a copy constructor?
DE Shaw Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits