title: Check Possible Sort Array Conditional Swapping Adjacent Allowed
signature: def check_possible_sort_array_conditional_swapping_adjacent_allowed(arr, n):
source_py: def check_possible_sort_array_conditional_swapping_adjacent_allowed(arr, n):
      for i in range(0, (n - 1)):
          if (arr[i] > arr[(i + 1)]):
              if ((arr[i] - arr[(i + 1)]) == 1):
                  (arr[i], arr[(i + 1)]) = (arr[(i + 1)], arr[i])
              else:
                  return False
      return True
source_cpp: bool check_possible_sort_array_conditional_swapping_adjacent_allowed(vector<int> arr, int n) {
    for ( int i = 0;
    i < n - 1;
    i ++ ) {
      if ( arr [ i ] > arr [ i + 1 ] ) {
        if ( arr [ i ] - arr [ i + 1 ] == 1 ) swap ( arr [ i ], arr [ i + 1 ] );
        else return false;
      }
    }
    return true;
  }
question_info.test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(arr, n, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              arr, n),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver([1, 4, 12, 16, 37, 44, 47, 51, 55, 57, 57, 62, 62, 62, 64, 69, 69, 70, 72, 81, 81, 88, 89, 97], 15, True)
      print(f"TEST-0...{result}")
  
      result = driver([-86, 0, 14, -16, -12, -72, 62, -34, -72, 30, 84, -60, 84, -64, 50, 74, 18, -82, -64, -64, -74, -56, 86, 84, -32, -10, 20, 4, 8, 96, 82, 26, 42], 18, False)
      print(f"TEST-1...{result}")
  
      result = driver([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], 31, True)
      print(f"TEST-2...{result}")
  
      result = driver([48, 66, 83, 12, 77, 98, 18, 33, 21, 16, 28, 24, 46, 43], 13, False)
      print(f"TEST-3...{result}")
  
      result = driver([-92, -58, -36, -28, -6, 2, 4, 26, 48, 58, 60, 62, 62, 98], 10, True)
      print(f"TEST-4...{result}")
  
      result = driver([0, 0, 0, 1, 0, 1], 4, True)
      print(f"TEST-5...{result}")
  
      result = driver([22, 38, 41, 41, 42, 51, 54, 58, 68, 76, 80, 85], 9, True)
      print(f"TEST-6...{result}")
  
      result = driver([84, -38, 52, -72, -24, 82, 54, 74, 0], 8, False)
      print(f"TEST-7...{result}")
  
      result = driver([0, 1, 1], 2, True)
      print(f"TEST-8...{result}")
  
      result = driver([63, 31, 14, 19, 77, 64, 62, 23, 22, 19, 39, 9, 79, 1, 87, 29, 58, 3, 3, 39, 1, 39, 35, 64, 64], 13, False)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.entry_fn_name: check_possible_sort_array_conditional_swapping_adjacent_allowed
question_info.test_list: [{"idx": 0, "outputs": true, "inputs": {"arr": [1, 4, 12, 16, 37, 44, 47, 51, 55, 57, 57, 62, 62, 62, 64, 69, 69, 70, 72, 81, 81, 88, 89, 97], "n": 15}}, {"idx": 1, "outputs": false, "inputs": {"arr": [-86, 0, 14, -16, -12, -72, 62, -34, -72, 30, 84, -60, 84, -64, 50, 74, 18, -82, -64, -64, -74, -56, 86, 84, -32, -10, 20, 4, 8, 96, 82, 26, 42], "n": 18}}, {"idx": 2, "outputs": true, "inputs": {"arr": [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], "n": 31}}, {"idx": 3, "outputs": false, "inputs": {"arr": [48, 66, 83, 12, 77, 98, 18, 33, 21, 16, 28, 24, 46, 43], "n": 13}}, {"idx": 4, "outputs": true, "inputs": {"arr": [-92, -58, -36, -28, -6, 2, 4, 26, 48, 58, 60, 62, 62, 98], "n": 10}}, {"idx": 5, "outputs": true, "inputs": {"arr": [0, 0, 0, 1, 0, 1], "n": 4}}, {"idx": 6, "outputs": true, "inputs": {"arr": [22, 38, 41, 41, 42, 51, 54, 58, 68, 76, 80, 85], "n": 9}}, {"idx": 7, "outputs": false, "inputs": {"arr": [84, -38, 52, -72, -24, 82, 54, 74, 0], "n": 8}}, {"idx": 8, "outputs": true, "inputs": {"arr": [0, 1, 1], "n": 2}}, {"idx": 9, "outputs": false, "inputs": {"arr": [63, 31, 14, 19, 77, 64, 62, 23, 22, 19, 39, 9, 79, 1, 87, 29, 58, 3, 3, 39, 1, 39, 35, 64, 64], "n": 13}}]
question_info.entry_cls_name: Solution