Find the first occurrence of the word "the"

Report a typo

Write a program that takes a sentence as input and returns the index of the first occurrence of the word "the", regardless of the capitalization. If there is no occurrence of it must output -1.

For instance, if the sentence is “The apple is red.” the output should be 0, if the sentence is “I ate the red apple.” the output should be 6, and if the sentence is “I love apples.” the output should be -1.

Note, the and The are equal.

Sample Input 1:

The apple is red.

Sample Output 1:

0

Sample Input 2:

I ate the red apple.

Sample Output 2:

6
Write a program in Kotlin
fun main() {
// write your code here
}
___

Create a free account to access the full topic