Back to videos
Correct Code Video
Case Files Core Skill

Case File 001: Find Target Element

Practice reading the problem, finding the shape, and preserving correctness.

Lesson Briefing

What this video teaches

This video walks through Case File 001: Find Target Element, the first direct-scan investigation in the Correct Code Framework. The problem asks the learner to determine whether a target value exists inside an unsorted array of integers and return the first index if found, otherwise return -1.

The lesson teaches learners to slow down and read the problem like evidence before choosing a tool. The Case File begins by opening the investigation, then moves into the Problem Space: an unsorted array, a target value, one active candidate at a time, and a sequential search path. Because the array is unsorted and the target can appear anywhere, the lawful shape is a linear scan.

The video emphasizes the core invariant for this case: the current candidate qualifies only if candidate == target. Every inspected value must be compared against the target, and every non-matching value is rejected without changing the answer. Since the solution only needs the first qualifying index, no Recorder is required. The investigation does not need a hash map, set, nested loop, graph, or memory structure because there is no prior evidence to preserve.

The walkthrough shows the execution phase step by step: select the candidate, compare it to the target, check whether the invariant is satisfied, and resolve by returning the index or continuing the scan. The sample investigation checks candidates until index 2 contains the target value 7, proving that index 2 is the correct answer.

The lesson closes by connecting the reasoning to code. Across languages such as JavaScript, Python, and C#, the syntax changes, but the proof stays the same: scan left to right, compare each candidate to the target, return the index on match, and return -1 only after exhaustion. The final message reinforces the CCF principle that the invariant determines qualification before execution, and execution verifies the proof.