AD8232 heart monitor: calculating BPM

Hey! For a project in school, I’m using the AD8232 heart rate sensor by sparkfun. I tried writing code myself for calculating the heart rate in BPM (the sensor just reads in an analog signal, identifying the electrical activity of the heart), but failed horribly doing this. So i decided to go online to look for code, doing this. I quickly came across the following script, made by viron11111 on Github.

unsigned int average_value[60];
int i = 0;

long lastDebounceTime = 0;
long debounceDelay = 300;

long counter = 0;

void setup() {
  // initialize the serial communication:
  Serial.begin(9600);
  pinMode(10, INPUT); // Setup for leads off detection LO +
  pinMode(3, INPUT); // Setup for leads off detection LO -

  attachInterrupt(0, right_Hand_Detect, FALLING);
  //attachInterrupt(1, left_Hand_Detect, FALLING);

}

void loop() {
  float sum = 0.0;
  float average = 0.0;
  
  if((digitalRead(10) == 1)||(digitalRead(11) == 1)){
    Serial.print('!');
  }
  else{
    //Serial.print('@');
    if ((millis() - lastDebounceTime) > debounceDelay){
      average_value[i] = analogRead(A0);
      i++;
      
      if (i >= 30){
        for (int j = 0; j < 60; j++){
          sum = sum + average_value[j];
          if (average_value[j] > 370){
            Serial.println(average_value[j]);
          }
          //Serial.println(average);
        }
        average = sum/60.0;
        //Serial.print("The Average is: ");
        //Serial.println(average);
        i = 0;
      }
    }
  }
  //Wait for a bit to keep serial data from saturating
  delay(1);
}

void right_Hand_Detect(){
  if(digitalRead(3) == 0){
    //Serial.print(counter);
    //Serial.println("Right hand");
    //counter++;
    lastDebounceTime = millis();
    Serial.println(lastDebounceTime);
  }
}

/*void left_Hand_Detect(){
  Serial.print(counter);
  Serial.println("Left hand");
  counter++;
}*/

This code seems to work, but i dont really understand how it works and how the interupts work. Could somebody help me with this?

Could somebody help me with this?

Without knowing what is connected to the external interrupt pin? No.

Are we also supposed to guess what it connected to pins 10, 11, and A0?