FastPrepDecode Three Interleaved Lines

Decode Three Interleaved Lines

Abridge logoAbridge● EasyFULLTIMEOA

Problem statement

The first three lines of a secret diary contain a hidden message. You are given them as three equal-length strings, line1, line2, and line3.

Read the characters column by column. For each position, take the character from line1, then line2, then line3. Join them in that order and return the decoded message.

Practice details

For this exercise, assume the lines contain printable ASCII characters and each has length from 0 to 10000. If the lines are empty, return an empty string.

Function

decodeMessage(line1: String, line2: String, line3: String) → String

Examples

Example 1

line1 = "adg"line2 = "beh"line3 = "cfi"return = "abcdefghi"

The three columns give abc, def, and ghi. Joining them gives abcdefghi.

Example 2

line1 = ""line2 = ""line3 = ""return = ""

There are no columns, so the decoded message is empty.

Example 3

line1 = "A1"line2 = "B2"line3 = "C3"return = "ABC123"

The first column gives ABC and the second gives 123.

Constraints

  • Each line has length from 0 to 10000.
  • All three lines have the same length.
  • Every character is printable ASCII, with code from 32 through 126.

More Abridge problems

See Abridge hiring insights
Saved
public String decodeMessage(String line1, String line2, String line3) {
    // Write your code here.
}
Checking account…