Ctrl K
Frontend · Junior · Coding

Write a function parseQuery without using URLSearchParams. It takes a query string, for example question mark, a equals one, ampersand, b equals two, and returns an object with the keys and values. If a key repeats, its values are collected into an array.

~15 min by voice

How to approach it

The interviewer is checking careful string handling and attention to edge cases: the leading "?", repeated keys, a key without a value, "=" inside a value, empty segments and decoding. It also matters whether you clarify the requirements before writing code and check the solution on an example.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsДана строка. Найдите длину самой длинной подстроки, в которой все символы различны. Например, для строки «abcabcbb» ответ 3 — это подстрока «abc». Mid-levelWhy are strings immutable in Java, and why shouldn't you concatenate strings with plus in a loop? JuniorДана строка из скобок трёх видов: круглых, квадратных и фигурных. Проверьте, является ли она правильной скобочной последовательностью. Например, «([]{})» — правильная, а «([)]» — нет. Mid-levelДан список слов. Сгруппируйте слова, которые являются анаграммами друг друга. Например, из слов eat, tea, tan, ate, nat, bat получится три группы: eat, tea, ate; tan, nat; bat. Mid-level

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~15 min