Detect Label Leakage via Temporal Check

~12 mincode completion

Implement find_leaking_indices(feature_times, label_times) returning a sorted integer array.

Examples

One leak at index 1 where feature_time > label_time

Input
find_leaking_indices([1, 5, 3], [3, 4, 7])
Output
[1]

All features recorded before labels: no leakage

Input
find_leaking_indices([1, 2, 3], [4, 5, 6])
Output
[]

Feature time exactly equal to label time counts as leakage

Input
find_leaking_indices([3, 3, 3], [3, 4, 2])
Output
[0, 2]

Hints

Hint 1

picks between two values elementwise without branching.

Hint 2

Watch for this: used strict greater than missing equal case.

Requirements

  • feature_times: 1D array of feature observation timestamps

  • label_times: 1D array of label observation timestamps

  • Return Sorted 1D integer array of leaking sample indices.

Constraints

  • Allowed library: NumPy only

  • Time limit: 200 ms, Memory: 64 MB

Where this shows up

~12 min

8 employers weight this skill

3 big tech firms, 2 enterprise vendors, 1 defense company, 1 AI product company, 1 health and bio company. Top match scores 87.

Python
import numpy as np

def find_leaking_indices(feature_times: np.ndarray, label_times: np.ndarray) -> np.ndarray:
    """
    Return sorted indices where feature_times[i] >= label_times[i] (temporal leakage).

    Args:
        feature_times: 1D array of feature observation timestamps
        label_times:   1D array of label observation timestamps

    Returns:
        Sorted 1D integer array of leaking sample indices.
    """
    # YOUR CODE HERE
    pass
Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.