Introduction

Hello and welcome to our exciting exploration of Scala string manipulation! In today's lesson, you'll discover an intriguing way to select characters from a string using Scala's immutable StringOps and powerful collection methods. We aim to explain this in such a comprehensive and concise way that you'll master it swiftly. Let's dive in!

Task Statement

Imagine this: You are given a string, and you must traverse it to pick its characters in an unusual order. Start with the first character, then move to the last, pick the second character, then the second-to-last, and so on, until no characters are left to select. Sounds fascinating, doesn't it?

Here's what we mean:

You need to write a Scala function solution(inputString: String): String. This function will take inputString as a parameter, a string composed of lowercase English alphabet letters ('a' to 'z') with a length between 1 to 100 characters. The function will return a new string derived from the input string with characters selected in the aforementioned order.

For example, if inputString is "abcdefg", the function should return "agbfced".

Solution Building: Step 1 - Initialization
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