Prob, C/C++ Programming

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given permutation is the lexicographically least permutation, then print the input permutation itself.

Input Format:
First line is the value of integer n: 1 <= n <= 1,000,000
Second line is a space separated list of integers 1 2 ... n permuted in some random order

Output Format: Output a single line containing a space separated list of integers which is the lexicographically preceding permutation of the input permutation.
Posted Date: 10/13/2014 9:05:23 AM | Location : USA







Related Discussions:- Prob, Assignment Help, Ask Question on Prob, Get Answer, Expert's Help, Prob Discussions

Write discussion on Prob
Your posts are moderated
Related Questions
Question 1 Write a program in ‘C' to check whether a given number is even or odd Question 2 Explain while and do... while loop with an example Question 3 Write a program

Write a program that reads data into an array of type int. You must use an array. The numbers input are attendance numbers at a conference. Keep a running average, number of events

Write a program that counts from 0 to 99 and prints these numbers to the terminal ie it prints 00, 01, 02, 03, 04, 05, ....,99. Graphics 1. Write a program in rPeANUt that

when you allocate memory with new[], you ought to free the memory via delete[]. While you allocate memory along 'new', then use 'delete' with no the brackets. You employ new[] to a

Explain some String Oriented Library Functions? To make simpler string processing we can use special string oriented library functions. Mainly the C compilers include library f

Q: Name the operators which cannot be overloaded? A:sizeof, ., .*, .->, ::, ?:


Overloading a method (or function) in C++ is the ability for functions of the similar name to be defined as long as these methods have dissimilar signatures (different set of param

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that