title: Program Check Array Sorted Not Iterative Recursive 1
signature: class Solution {
  
      public bool ProgramCheckArraySortedNotIterativeRecursive1(List<int> arr, int n) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(bool actual, bool expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(List<int> arr, int n, bool expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                bool pred_result = solution_cls.PLACEHOLDER_FN_NAME(arr, n); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  new List<int>{6, 8, 8, 16, 19, 19, 21, 23, 26, 33, 34, 36, 38, 39, 41, 41, 45, 47, 52, 52, 55, 57, 60, 60, 60, 61, 69, 69, 70, 70, 72, 73, 73, 75, 78, 81, 84, 84, 85, 88, 88, 89, 90, 91, 97}, 22, 
                  true
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{2, -90, 66, 24, -18, 70, 34, 18, 84, -62}, 9, 
                  false
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{1, 1}, 1, 
                  true
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{12, 88, 65, 82, 23, 39, 60, 27, 57, 44, 70, 28, 23, 34, 25, 11, 48, 65, 10, 73, 26, 10, 18, 60, 73, 45, 26, 9, 36, 15, 24, 40, 2, 4, 95, 20, 39, 45}, 23, 
                  false
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-38, 38, 40, 72}, 2, 
                  true
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{1, 0, 0, 0, 1}, 3, 
                  false
              );
              Console.WriteLine(string.Format(
                  "TEST-5...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{11, 15, 16, 17, 17, 17, 22, 23, 23, 25, 27, 28, 28, 31, 33, 36, 38, 40, 42, 44, 46, 49, 51, 51, 52, 60, 62, 65, 67, 71, 74, 77, 77, 78, 78, 79, 83, 83, 86, 86, 87, 87, 87, 88, 91, 92, 97, 97, 97}, 44, 
                  true
              );
              Console.WriteLine(string.Format(
                  "TEST-6...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-26, -90, -78, -76, -58, -64, -72, -34, -58, -48, 78, -50, -30, 26, -60, 26}, 9, 
                  false
              );
              Console.WriteLine(string.Format(
                  "TEST-7...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 23, 
                  true
              );
              Console.WriteLine(string.Format(
                  "TEST-8...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{56, 51, 63, 30, 10, 88, 23, 1, 48, 4, 28, 44}, 10, 
                  false
              );
              Console.WriteLine(string.Format(
                  "TEST-9...{0}",
                  result)
              );
          }
      }
  }
  
source_py: def program_check_array_sorted_not_iterative_recursive_1(arr, n):
      if ((n == 0) or (n == 1)):
          return True
      for i in range(1, n):
          if (arr[(i - 1)] > arr[i]):
              return False
      return True
source_cpp: bool program_check_array_sorted_not_iterative_recursive_1(vector<int> arr, int n) {
    if ( n == 0 || n == 1 ) return true;
    for ( int i = 1;
    i < n;
    i ++ ) if ( arr [ i - 1 ] > arr [ i ] ) return false;
    return true;
  }