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.

Find first non-repeating character index

Company: Goldman Sachs

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

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.

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.

Hints

  1. Track sum and count per student, then scan averages.

Loading coding console...