The TransCompilator

Solved LeetCode program · 34 of 1,000

#0034 · Find First and Last Position of Element in Sorted Array

Medium Array chunk-01.md

Original English source

Start with the list of numbers 5, 7, 7, 8, 8, and 10. The target is 8. The first is -1. The last is -1.
For every position from 0 to the last position of numbers.
If item position of numbers is target and first is -1, set first to position. If item position of numbers is target, set last to position.

Display first. Display last.

Open in Playground Browse all 1,000 problems

Expected stdout

3
4