title: Count Frequency K Matrix Size N Matrixi J Ij
signature: function countFrequencyKMatrixSizeNMatrixiJIj(n: number, k: number): number {
source_py: def count_frequency_k_matrix_size_n_matrixi_j_ij(n, k):
      if ((n + 1) >= k):
          return (k - 1)
      else:
          return (((2 * n) + 1) - k)
source_cpp: int count_frequency_k_matrix_size_n_matrixi_j_ij(int n, int k) {
    if ( n + 1 >= k ) return ( k - 1 );
    else return ( 2 * n + 1 - k );
  }
question_info.test_list: [{"idx": 0, "outputs": 73, "inputs": {"n": 90, "k": 74}}, {"idx": 1, "outputs": 35, "inputs": {"n": 86, "k": 36}}, {"idx": 2, "outputs": 37, "inputs": {"n": 92, "k": 38}}, {"idx": 3, "outputs": 70, "inputs": {"n": 72, "k": 71}}, {"idx": 4, "outputs": -6, "inputs": {"n": 25, "k": 57}}, {"idx": 5, "outputs": -30, "inputs": {"n": 11, "k": 53}}, {"idx": 6, "outputs": 79, "inputs": {"n": 94, "k": 80}}, {"idx": 7, "outputs": 74, "inputs": {"n": 91, "k": 75}}, {"idx": 8, "outputs": 57, "inputs": {"n": 66, "k": 58}}, {"idx": 9, "outputs": -19, "inputs": {"n": 34, "k": 88}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(n: number, k: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n, k),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(90, 74, 73);
    console.log(`TEST-0...${result}`);
  
    result = driver(86, 36, 35);
    console.log(`TEST-1...${result}`);
  
    result = driver(92, 38, 37);
    console.log(`TEST-2...${result}`);
  
    result = driver(72, 71, 70);
    console.log(`TEST-3...${result}`);
  
    result = driver(25, 57, -6);
    console.log(`TEST-4...${result}`);
  
    result = driver(11, 53, -30);
    console.log(`TEST-5...${result}`);
  
    result = driver(94, 80, 79);
    console.log(`TEST-6...${result}`);
  
    result = driver(91, 75, 74);
    console.log(`TEST-7...${result}`);
  
    result = driver(66, 58, 57);
    console.log(`TEST-8...${result}`);
  
    result = driver(34, 88, -19);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: countFrequencyKMatrixSizeNMatrixiJIj
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js