FastPrepRun-Length Encoding
Problems/Run-Length Encoding

Run-Length Encoding

Expedia logoExpedia● EasyFULLTIMENEW GRADINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported run-length example and count-one convention are preserved. Case-sensitive English-letter domain, empty-input behavior and finite bounds complete the interface; estimated match 95%.

Encode every maximal run of equal consecutive characters in s as the character followed by the decimal run length. Include the count even when it is 1. Runs separated by a different character stay separate.

Character comparison is case-sensitive. Return an empty string for an empty input.

Function

runLengthEncode(s: String) → String

Examples

Example 1

s = "aaaabbbccdaa"return = "a4b3c2d1a2"

The runs are aaaa, bbb, cc, d, aa, with lengths 4,3,2,1,2.

Example 2

s = "aA"return = "a1A1"

The two letters differ in case and form separate runs.

Constraints

  • 0 <= s.length <= 20000.
  • s contains only uppercase or lowercase English letters.

More Expedia Online Assessment questions

  • Balanced NumbersOA · Seen Aug 2026
  • REST API: Discounted PriceOA · Seen Aug 2026
  • Maximum Team SizeOA · Seen Mar 2026
  • Per-Domain Request LimiterOA · Seen Oct 2025
  • Count Equal-Frequency SubsequencesOA · Seen Mar 2025
  • Count Increasing Stock PeriodsOA · Seen Mar 2025
  • Get Minimum StepsOA · Seen Oct 2024
  • Rank Songs by PopularityOA · Seen Oct 2024
  • Calculate the SumOA · Seen Oct 2024
  • Get Maximum EfficiencyOA · Seen Oct 2024

Similar questions at other companies

  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • Branch with the Most FilesCapital One · OACapital One interview questions
  • REST API: Highest International StudentsRippling · OARippling interview questions
  • Rearrange String by Alternating EndsHudson River Trading · OAHudson River Trading interview questions
  • Filter Isolated Interior Signal BitsSEDEMAC · OA
  • Scale Ingredient QuantitiesUpstart · OAUpstart interview questions
  • Telephone Keypad String EncodingEpic · OAEpic interview questions
  • Count Invalid Log GroupsIBM · OAIBM interview questions
  • Count Case-Insensitive TripletsTikTok · OATikTok interview questions
  • Simulate a Deterministic Finite AutomatonPoint72 · OAPoint72 interview questions

Interview reports that mention this question

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia New Grad SDE Earlier Loops: 5 Experiences (Part 2 of 3)

Expedia interview experiences

  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public String runLengthEncode(String s) {
        // Write your code here.
    }
}
Checking account…