Parse Comma-Separated Text
Updated
Problem statement
Split text into fields at every comma character ,. Return the fields in their original order.
For this exercise, assume commas are the only separators. Preserve every other character, including spaces and quotation marks. There is no quoting or escape syntax. Preserve empty fields before, between, and after commas. Empty text has one empty field.
For example, a,,b, produces four fields: a, an empty string, b, and an empty string.
Function
parseFields(text: String) → String[]Examples
Example 1
text = "a,b,,c,"return = ["a","b","","c",""]Four commas divide the text into five fields. The adjacent commas make the third field empty, and the final comma makes the fifth field empty.
Example 2
text = " Alice ,Bob"return = [" Alice ","Bob"]The comma separates two fields. The spaces before and after Alice are ordinary characters and stay in the first field.
Constraints
- For this exercise, assume
0 <= text.length <= 10000. - Every character is printable ASCII, with code from 32 through 126, inclusive.
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
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- First Non-Repeating CharacterAmazon · OA · ONSITE INTERVIEW
- Maximum Ones After K OperationsGoldman Sachs · OAGoldman Sachs interview questions
- Total Each Letter's Count in an Encoded StringIBM · OAIBM interview questions
- Find Words That Can Be Formed by CharactersTabaPay · OA
- Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
- Count Palindrome Addition ChoicesThe D.E. Shaw Group · OAThe D.E. Shaw Group interview questions
- Count Palindrome Addition ChoicesHudson River Trading · OAHudson River Trading interview questions
- Count Phrases Formed by Anagram ReplacementWells Fargo · OAWells Fargo interview questions
- Count Substrings With Identical CharactersVirtu Financial · OAVirtu Financial interview questions