Introduction

Hello, and welcome to our analysis lesson. Today, we will be exploring a classic problem in the realm of string manipulations. We'll learn how to locate all occurrences of a substring within a larger string using Scala. The techniques you will learn can be utilized in scenarios such as text processing and data analysis. Are you ready to dive in? Let's get started!

Task Statement and Description

Here's our challenge: we have two lists of strings of the same length, one containing the "original" strings and the other containing the "substrings." Our task is to identify all occurrences of each substring within its corresponding original string and return a list of the starting indices of these occurrences. Remember, index counting should start from 0.

Example

If we take the following lists:
Original List: List("HelloWorld", "LearningScala", "GoForBroke", "BackToBasics")
Substring List: List("loW", "ear", "o", "Ba").

This will produce the following outputs:
In "HelloWorld", "loW" starts at index 3.
In "LearningScala", "ear" starts at index 1.
In "GoForBroke", "o" appears at indices 1, 3, and 7.
In "BackToBasics", starts at indices 0 and 6.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal