The TransCompilator

Solved LeetCode program · 579 of 1,000

#0806 · Number of Lines To Write String

Easy Array chunk-12.md

Original English source

Keep a shared alphabet as empty text. Place "abcdefghijklmnopqrstuvwxyz" into alphabet. Keep a shared widths holding 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, and 10. Keep a shared sentence as empty text. Place "abcdefghijklmnopqrstuvwxyz" into sentence. Keep a shared target as empty text. Keep a shared found of 0. Keep a shared used of 0. Keep a shared sheets of 1.
To search from spot (a whole number). If spot is more than 25, return. The piece is the slice of alphabet from spot to spot plus 1. If piece matches target, set found to spot, return. Search from spot plus 1.

For every spot from 0 to the last position of sentence.
Set target to the slice of sentence from spot to spot plus 1. Set found to -1. Search from 0. The letter is found. The room is item letter of widths. If used plus room is more than 100, add 1 to sheets, set used to room, otherwise add room to used.

Show sheets. Show used.

Open in Playground Browse all 1,000 problems

Expected stdout

3
60