/**
 * Given a voltageTable - a list of lists representing the voltage values of different components,
 * and componentId - an integer representing the id of the component,
 * this function returns the voltage value of the specified component.
 *
 * Each component is represented by a list of voltage values at different time intervals.
 * The format of the voltageTable is as follows:
 * [[v1, v2, v3, ...],         // Voltage values for component 0
 *  [v1, v2, v3, ...],         // Voltage values for component 1
 *  ...
 *  [v1, v2, v3, ...]]         // Voltage values for component n
 *
 * The function will return the voltage value of the desired component at the earliest time interval.
 * If the componentId or voltageTable is empty, the function returns null.
 */
fun findComponent(voltageTable: List<List<Int>>, componentId: Int): Int? {

    if (voltageTable.isEmpty() || componentId >= voltageTable.size || componentId < 0) {
        return null
    }
    return voltageTable[componentId][0]
}
/**
 * Given a voltageTable - a list of lists representing the voltage values of different components,
 * and componentId - an integer representing the id of the component,
 * this function returns the voltage value of the specified component.
 *
 * Each component is represented by a list of voltage values at different time intervals.
 * The format of the voltageTable is as follows:
 * [[v1, v2, v3, ...],         // Voltage values for component 0
 *  [v1, v2, v3, ...],         // Voltage values for component 1
 *  ...
 *  [v1, v2, v3, ...]]         // Voltage values for component n
 *
 * The function will return the voltage value of the desired component at the earliest time interval.
 * If the componentId or voltageTable is empty, the function returns null.
 */
fun findComponent(voltageTable: List<List<Int>>, componentId: Int): Int? {
/**
 * Given a voltageTable - a list of lists representing the voltage values of different components,
 * and componentId - an integer representing the id of the component,
 * this function returns the voltage value of the specified component.
 *
 * Each component is represented by a list of voltage values at different time intervals.
 * The format of the voltageTable is as follows:
 * [[v1, v2, v3, ...],         // Voltage values for component 0
 *  [v1, v2, v3, ...],         // Voltage values for component 1
 *  ...
 *  [v1, v2, v3, ...]]         // Voltage values for component n
 *
 * The function will return the voltage value of the desired component at the earliest time interval.
 * If the componentId or voltageTable is empty, the function returns null.
 */
fun findComponent(voltageTable: List<List<Int>>, componentId: Int): Int? {

    if (voltageTable.isEmpty() || componentId >= voltageTable.size || componentId < 0) {
        return null
    }
    return voltageTable[componentId][0]
}