The TransCompilator

Solved LeetCode program · 821 of 1,000

#1078 · Occurrences After Bigram

Easy String chunk-17.md

Original English source

The sentence is "alice is a good girl she is a good student". The firstraw is "a". The secondraw is "good". The first is empty text. Place firstraw into first. The second is empty text. Place secondraw into second. The parts is split sentence by " ". The answers is an empty list of text. The last is the last position of parts.
For every spot from 0 to last minus 2.
The leftraw is item spot of parts. The middleraw is item (spot plus 1) of parts. The rightraw is item (spot plus 2) of parts. The leftword is empty text. Place leftraw into leftword. The middleword is empty text. Place middleraw into middleword. The rightword is empty text. Place rightraw into rightword. The leftsame is 0. If leftword matches first, set leftsame to 1. The middlesame is 0. If middleword matches second, set middlesame to 1. If leftsame is 1 and middlesame is 1, Place rightword into answers.

For each word in answers, Show word.

Open in Playground Browse all 1,000 problems

Expected stdout

girl
student