HTML & JS
using System;
using System.Text;

class Program
    {
        static void Main(string[] args)
        {
            int testCases = int.Parse(Console.ReadLine().Trim());
            StringBuilder sb = new StringBuilder();
            while (testCases-- > 0)
            {
                int arrSize = int.Parse(Console.ReadLine().Trim());
                int[] arr = Array.ConvertAll(Console.ReadLine().Trim().Split(' '), int.Parse);

                for (int i = 0; i < arrSize - 1; i++)
                {
                    if (arr[i] > arr[i + 1])
                    {
                        sb.Append(arr[i + 1] + " ");
                    }
                    else
                        sb.Append("-1" + " ");

                }
                sb.Append("-1 \n" );                
            }
            Console.WriteLine(sb);
        }
    }

Generated URL:

Output:

2 1 -1 3 -1 
-1 2 -1 1 -1 -1 

Report Bug