Skip to main content

Posts

Showing posts from August, 2020

A number is given as input.Find the maximum number that can be formed using the digits.

  A number is given as input.Find the maximum number that can be formed using the digits. Input Size : N <= 10000000 Sample Testcase : INPUT 4123 OUTPUT 4321     const readline = require("readline"); const inp = readline.createInterface({   input: process.stdin }); const userInput = []; inp.on("line", (data) => {   userInput.push(data); }); inp.on("close", () => {       var inp = userInput[0];   var arr = inp.split("").map((val)=>Number(val))   var sarr = arr.sort(function(a,b){return b-a});   var ans  =sarr.join("")   console.log(ans)   });