FastPrepBetter Compression 🦀
Problems/Better Compression 🦀

Better Compression 🦀

Atlassian logoAtlassian● EasyINTERNOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Consider a string, S, that is a series of characters, each followed by its frequency as an integer. The string is not compressed correctly, so there may be multiple occurrences of the same character. A properly compressed string will consist of one instance of each character in alphabetical order followed by the total count of that character within the string.

Example The string 'a3c9b2c1' has two instances where 'c' is followed by a count: once with 9 occurrences, and again with 1. It should be compressed to 'a3b2c10'.

Function

betterCompression(S: String) → String

Complete the function betterCompression in the editor below.

betterCompression has the following parameter:

  1. S: string: a compressed string

Returns string: the properly compressed string

Examples

Example 1

S = "a3c9b2c1"return = "a3b2c10"

The string 'a3c9b2c1' has two instances where 'c' is followed by a count: once with 9 occurrences, and again with 1. It should be compressed to 'a3b2c10'.

Constraints

  • 1 ≤ size of S ≤ 100000
  • 'a' ≤ characters in S ≤ 'z'
  • 1 ≤ frequency of each character in S ≤ 1000

More Atlassian interview questions

  • Merge Overlapping IntervalsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Tennis Court SchedulingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Deterministic Word Guess SolverONSITE INTERVIEW · Seen Oct 2026
  • Generate Word Guess FeedbackONSITE INTERVIEW · Seen Oct 2026
  • Bounded Word Guess SolverONSITE INTERVIEW · Seen Oct 2026
  • Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
  • Word Guess Feedback ColorsONSITE INTERVIEW · Seen Oct 2026
  • Longest Consistent Activity StreakPHONE SCREEN · Seen Sep 2026
  • Music Player Operation SequencePHONE SCREEN · Seen Sep 2026
  • Underline Shortest Unique SubstringsPHONE SCREEN · Seen Aug 2026

Similar questions at other companies

  • Count User Mentions in Chat MessagesRamp · OARamp interview questions
  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
  • Flat JSON Value DifferencesChubb · OAChubb interview questions
  • Get Search ResultsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Lexicographic Word FrequenciesUpstart · OAUpstart interview questions
  • Email Log Processing, Grouping, and SortingStripe · OAStripe interview questions
  • Most Frequent CharacterMicrosoft · OAMicrosoft interview questions
  • Get Maximum Information GainAmazon · OA
  • Better CompressionGoldman Sachs · OAGoldman Sachs interview questions

Atlassian interview experiences

  • Atlassian MLE Phone Screen: Model Deployment Design: 1 Experience
  • Atlassian Coding Screens and Karat: 3 Experiences (Part 2 of 2)
  • Atlassian Full Stack Interviews: 11 Experiences (Part 1 of 2)
All Atlassian interview questionsSee Atlassian hiring insights
Saved
class Solution {
    public String betterCompression(String s) {
        // write your code here
    }

}
Checking account…