Esempio n. 1
0
        public Stack<int> RoundOnce(Stack<int> A)
        {

            Stack<int> B = new Stack<int>();

            int item = A.Pop();
            B.Push(item);

            for (int i = A.Count() - 1; i >= 0; i--)
            {
                B.Push(A.ElementAt(i));
            }
            return B;
        }
Esempio n. 2
0
        public int[] Solution(int[] A, int K)
        {
            Stack<int> B = new Stack<int>();
            if (A.Length == 0) return A;

            int[] res = new int[A.Length];
            for (int i = 0; i < A.Length; i++)
            {
                B.Push(A[i]);
            }
            for (int i = 0; i < K; i++)
            {
                B = RoundOnce(B);
            }
            for (int i = B.Count() - 1, j = 0; i >= 0; i--, j++)
            {
                res[j] = B.ElementAt(i);
            }
            return res;

        }