PracHub
QuestionsPremiumLearningGuidesInterview PrepCoaches
|Home/Coding & Algorithms/SoFi

Find maximum-occurring character in a string

Last updated: May 10, 2026

Quick Overview

This question evaluates proficiency in string manipulation and frequency counting, including correct handling of tie-breaking by earliest first occurrence and awareness of character-set distinctions.

  • easy
  • SoFi
  • Coding & Algorithms
  • Software Engineer

Find maximum-occurring character in a string

Company: SoFi

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Take-home Project

## Problem Given a non-empty string `s`, return the character that occurs the most times in `s`. ### Tie-breaking If multiple characters have the same maximum frequency, return the one whose **first occurrence index in `s` is smallest**. ### Input - A string `s` (characters are case-sensitive). ### Output - A single character: the maximum-occurring character under the tie-break rule. ### Constraints - `1 <= len(s) <= 2 * 10^5` - `s` may contain any printable ASCII characters (treat each distinct character separately). ### Example - Input: `"abcaac"` - Frequencies: `a=3, c=2, b=1` → Output: `a`

Quick Answer: This question evaluates proficiency in string manipulation and frequency counting, including correct handling of tie-breaking by earliest first occurrence and awareness of character-set distinctions.

Related Interview Questions

  • Find Smallest Common Row Value - SoFi (easy)
  • Format words into wrapped/justified lines - SoFi (medium)
  • Find the second most frequent tag - SoFi (medium)
  • Implement a multithreaded task executor with semaphores - SoFi (medium)
  • Implement chance of a personal best - SoFi (hard)
SoFi logo
SoFi
Jan 7, 2026, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
4
0
Coding Console
Loading...

Problem

Given a non-empty string s, return the character that occurs the most times in s.

Tie-breaking

If multiple characters have the same maximum frequency, return the one whose first occurrence index in s is smallest.

Input

  • A string s (characters are case-sensitive).

Output

  • A single character: the maximum-occurring character under the tie-break rule.

Constraints

  • 1 <= len(s) <= 2 * 10^5
  • s may contain any printable ASCII characters (treat each distinct character separately).

Example

  • Input: "abcaac"
  • Frequencies: a=3, c=2, b=1 → Output: a

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More SoFi•More Software Engineer•SoFi Software Engineer•SoFi Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.