Computer Science, asked by Vujayasree, 6 months ago

2. Develop a solution for the following


Given a string S, and two numbers N, M -
arrange the characters of string in between the indexes N and M (both
inclusive) in descending order. (Indexing starts from 0).

Input Format:

First line contains T - number of test cases.

Next T lines contains a string(S) and two numbers(N, M)
separated by spaces.


Output Format:

Print the modified string for each test case in new line.

Constraints:


1≤T≤1000


1≤|S|≤10000 // |S| denotes the length of
string.


0≤N≤M<|S|


S∈[a,z]
SAMPLE INPUT

3

hlleo 1 3

ooneefspd 0 8


effort 1 4

SAMPLE OUTPUT


hlleo


spoonfeed



erofft​

Answers

Answered by mujassamk200
0

Answer:

mxmdlrpcmfmflflflfmf.kxkx

Answered by naveednav05
3

Answer:

using System;

namespace Sorting_substring

{

   class Program

   {

       static string getString(char[] arr1)

       {

           

           string s = string.Join("", arr1);

           return s;

       }

       static void Main(string[] args)

       {

           string str;

           char[] arr1;

           

           

           Console.Write("Enter the string : ");

           str = Console.ReadLine();

           Console.Write("Enter Number 1: ");

           int num1 = Convert.ToInt32( Console.ReadLine());

           Console.Write("Enter Number 2 : ");

           int num2 = Convert.ToInt32(Console.ReadLine());

           int length = str.Length;

           arr1 = str.ToCharArray(0, length);

         Array.Sort(arr1, num1, num2);

           Array.Reverse(arr1, num1 ,num2);

          string str1 = getString(arr1);

           Console.Write("String Sorted from "+ num1 +" To " + num2 );

           Console.WriteLine("\n\n"+str1);

       }

   }

}

Explanation:

Hello!! I am Naveed. my knowledge in programming is medium. it took hours to understand the question and it took hours to find the solution. hope u like it.

  1. just used simple methods (Array.Sort(arr1, num1, num2);, Array.Reverse(arr1, num1 ,num2);.
  2. this is used to convert array to string string str1 = getString(arr1);
Similar questions