using
System;
using
System.Collections.Generic;
class
GFG {
static
List<List<
int
>> st =
new
List<List<
int
>>();
static
int
[,] add = {{1,2}, {1,3}};
static
void
find(List<
int
> inp, List<
int
> Out)
{
if
(inp.Count == 0)
{
if
(Out.Count != 0)
{
st.Add(Out);
}
return
;
}
List<
int
> temp =
new
List<
int
>();
temp.Add(inp[0]);
inp.RemoveAt(0);
find(inp, Out);
if
(Out.Count == 0)
find(inp, temp);
else
if
(temp[0] > Out[Out.Count - 1])
{
Out.Add(temp[0]);
find(inp, Out);
}
}
static
void
Main()
{
List<
int
> ls1 =
new
List<
int
>(
new
int
[]{ 1, 3, 2 });
List<
int
> ls2 =
new
List<
int
>();
find(ls1, ls2);
for
(
int
i = 0; i < st.Count; i++)
{
for
(
int
j = 0; j < st[i].Count; j++)
Console.Write(st[i][j] +
" "
);
Console.WriteLine();
}
for
(
int
i = 0; i < add.GetLength(0); i++)
{
for
(
int
j = 0; j < add.GetLength(1); j++)
Console.Write(add[i,j] +
" "
);
Console.WriteLine();
}
}
}