PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This composite question evaluates proficiency in string processing and frequency analysis for the first-unique-character task, and in data grouping and numeric aggregation for the highest-average-score task, focusing on use of associative structures and algorithmic reasoning.

  • nan
  • Goldman Sachs
  • Coding & Algorithms
  • Software Engineer

Find first non-repeating character index

Company: Goldman Sachs

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: nan

Interview Round: Technical Screen

You are given two separate coding tasks. ## Task 1: First Unique Character Given a string `s` (lowercase/ASCII letters), return the **index of the first character that appears exactly once** in the string. If no such character exists, return `-1`. **Input:** `s` (string) **Output:** integer index (0-based) or `-1` **Examples** - `s = "leetcode"` → `0` (character `'l'`) - `s = "loveleetcode"` → `2` (character `'v'`) - `s = "aabb"` → `-1` --- ## Task 2: Highest Average Score You are given a list of student score records. Each record contains a `student_id` (string) and a `score` (integer). A student can appear multiple times. Compute the **average score per student** (mean of all that student’s scores), and return the **maximum average** across all students. **Input:** list of pairs `[(student_id, score), ...]` **Output:** the highest average (as a floating-point value or as an exact rational; specify your choice during the interview) **Example** Input: `[("a", 80), ("b", 90), ("a", 100)]` - avg(a) = (80 + 100) / 2 = 90 - avg(b) = 90 Output: `90` **Notes / Clarifications to ask:** - Should ties return just the value, or also the student id(s)? - How should rounding be handled if the average is not an integer?

Quick Answer: This composite question evaluates proficiency in string processing and frequency analysis for the first-unique-character task, and in data grouping and numeric aggregation for the highest-average-score task, focusing on use of associative structures and algorithmic reasoning.

First Unique Character Index

Return the first index whose character appears exactly once, or -1.

Constraints

  • s is lowercase or ASCII

Examples

Input: ('leetcode',)

Expected Output: 0

Explanation: l at index 0.

Input: ('loveleetcode',)

Expected Output: 2

Explanation: v at index 2.

Input: ('aabb',)

Expected Output: -1

Explanation: No unique character.

Input: ('',)

Expected Output: -1

Explanation: Empty string.

Hints

  1. Count frequencies, then scan in original order.

Highest Average Score

Return the maximum average score across students.

Examples

Input: ([('a', 80), ('b', 90), ('a', 100)],)

Expected Output: 90.0

Explanation: Prompt example.

Input: ([],)

Expected Output: None

Explanation: No records.

Input: ([('x', 1), ('x', 2), ('y', 2)],)

Expected Output: 2.0

Explanation: Fractional average comparison.

Hints

  1. Track sum and count per student, then scan averages.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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
  • AI Coding 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.

Related Coding Questions

  • Design a Workspace Resource Manager - Goldman Sachs (medium)
  • Implement an Integer Hash Map - Goldman Sachs
  • Solve string and hashmap coding tasks - Goldman Sachs (medium)
  • Implement a String Deque - Goldman Sachs (easy)
  • Solve string and hashmap interview tasks - Goldman Sachs (medium)