FastPrepOne-Hot String Matrix
Problems/One-Hot String Matrix

One-Hot String Matrix

Intuit logoIntuit● MediumINTERNOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report specifies sorted one-hot columns and preserved positions, but its sample repeats zero in the position column. This version follows the prose and preserves each input position; about 90% match.

Each pair (positions[i], labels[i]) is one input row. Sort all distinct labels in ASCII lexicographic order. Return one string row per input row, in its original order. The first column is the decimal string for positions[i]. Each remaining column belongs to one sorted distinct label and contains "1" when that row has that label, otherwise "0".

Do not include a header row. Repeated position values and labels are allowed. Empty input returns an empty matrix.

Function

oneHotMatrix(positions: int[], labels: String[]) → String[][]

Examples

Example 1

positions = [0,1,2,3]labels = ["Berkeley","Berkeley","Berkeley","Columbia"]return = [["0","1","0"],["1","1","0"],["2","1","0"],["3","0","1"]]

Berkeley sorts before Columbia; the positions remain 0,1,2,3.

Example 2

positions = [7,7]labels = ["z","a"]return = [["7","0","1"],["7","1","0"]]

Rows keep their input order, while columns sort by label.

Constraints

  • For this exercise, assume equal input lengths at most 10000; labels are nonempty ASCII strings of at most 32 characters.
  • If u labels are distinct, positions.length * (u+1) <= 100000. Positions are signed 32-bit integers.

More Intuit Online Assessment questions

  • Employee Promotion OpportunitiesOA · Seen Oct 2026
  • Next Pascal Row CoefficientOA · Seen Oct 2026
  • Parse Router LogsOA · Seen Oct 2026
  • Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
  • Maximum Square-Free DivisorOA · Seen Oct 2026
  • Two Tribes from Taller-Person CountsOA · Seen Oct 2026
  • Shortest Path from an Encoded GraphOA · Seen Sep 2026
  • Oldest and Youngest EmployeesOA · Seen Sep 2026
  • Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
  • Submask Sum QueriesOA · Seen Sep 2026

Similar questions at other companies

  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN
  • Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Minimum Distinct Prefix CostChubb · OAChubb interview questions
  • Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
  • Convert Sparse Records to a Filled TableNetflix · OANetflix interview questions
  • Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
  • Aggregate Paginated Project Run RecordsReplit · OA
  • Rank Teams by VotesAtlassian · OAAtlassian interview questions
  • Efficient TeamsExpedia · OAExpedia interview questions

Interview reports that mention this question

  • Intuit OA: What It Tests (2026)

Intuit interview experiences

  • Intuit Software Engineering Intern - Full Stack OA Format
All Intuit interview questionsSee Intuit hiring insights
Saved
class Solution {
    public String[][] oneHotMatrix(int[] positions, String[] labels) {
        // Write your code here
    }
}
Checking account…