The TransCompilator

Solved LeetCode program · 924 of 1,000

#1287 · Element Appearing More Than 25% In Sorted Array

Easy Array chunk-19.md

Original English source

The values is a list of 1, 2, 2, 6, 6, 6, 6, 7, and 10. The last is the last position of values. The total is last plus 1. The current is item 0 of values. The run is 0. The answer is 0.
For each value in values.
If value is current, add 1 to run, otherwise set current to value, set run to 1. If answer is 0 and run times 4 is more than total, set answer to value.

Show answer.

Open in Playground Browse all 1,000 problems

Expected stdout

6