# searching advanced

How Many Times Does It Appear?

The librarian wants to know how many copies of one book the sorted shelf holds — without touching every book. 📚

You get a SORTED list of nums and a target (which might not be there at all). Print how many times it appears. Hint: first appearance and last appearance tell you everything.

Example:

Input: nums = [1, 4, 4, 4, 7], target = 4 Output: 3

The first appearance is at position 1 and the last is at position 3, so the count is 3 - 1 + 1 = 3.

💡 need a hint?

srch-count-via-bounds.py🔒 given lines are locked — write your code in between
loading...