Problem Statement | |||||||||||||
You have a lot of CDs that you have placed into one big box. You are given a String diskNames containing a single-space separated list of the disk names (the names will not contain spaces). The first disk is at the bottom of the box, the second lies directly on top of the first disk, and so on. Return the number of disks you'll need to take out of the box to find the disk named searchingDisk. You only need to take out the disks that are on top of searchingDisk. You do not need to take out the disk you're looking for. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | diskNames will contain between 1 and 50 characters, inclusive. | ||||||||||||
- | searchingDisk will contain between 1 and 10 characters, inclusive. | ||||||||||||
- | diskNames will contain only lowercase letters ('a'-'z') and spaces (' '). | ||||||||||||
- | searchingDisk will contain only lowercase letters ('a'-'z'). | ||||||||||||
- | Disk names will be separated by exactly one space in diskNames. | ||||||||||||
- | searchingDisk will be one of the disk names in diskNames. | ||||||||||||
- | diskNames will not contain duplicate disk names. | ||||||||||||
- | diskNames will not contain leading or trailing spaces | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|