Mental Model
Find where a number first appears and where it last appears in a list by checking each item one by one.
Analogy: Imagine a row of mailboxes with letters inside. You want to find the first and last mailbox that has a letter from your friend. You look from left to right to find the first mailbox, and from right to left to find the last mailbox.
Index: 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> null
Value: 1 -> 2 -> 3 -> 2 -> 4 -> 2 -> 5 -> null
โsearch target=2