Backtick Identifier Converter
Updated
Problem statement
You are given a string text. Some identifiers in the string are wrapped in backticks, such as `user_id`.
For every backtick-wrapped identifier:
- If the identifier is an all-uppercase constant, leave it unchanged.
- Otherwise, treat it as a snake_case function or variable name and convert it to camelCase.
Return the full string after converting only the text inside complete backtick pairs. Preserve the backticks and all text outside them.
An identifier is treated as an all-uppercase constant when it contains at least one letter and every letter in it is uppercase. Underscores and digits do not affect this check.
Function
convertIdentifiers(text: String) → String Complete convertIdentifiers.
String text: the text to transform
Returns String: the transformed text.
Examples
Example 1
text = "Call `get_user_name` before reading `MAX_RETRY_COUNT`."return = "Call `getUserName` before reading `MAX_RETRY_COUNT`."get_user_name is converted to camelCase, while the uppercase constant is unchanged.
Example 2
text = "Use `parse_http_response` and `user_id` now."return = "Use `parseHttpResponse` and `userId` now."Both snake_case identifiers inside backticks are converted and the rest of the text is preserved.
Constraints
- 1 <= text.length <= 10^5
textcontains printable ASCII characters.- Backtick-wrapped identifiers contain letters, digits, and underscores.
More Hudson River Trading Online Assessment questions
- Count Palindrome Addition ChoicesOA · Seen Nov 2026
- Count Multiples of Three with Two SevensOA · Seen Oct 2026
- Recursively Expanded Shell Command CountsOA · Seen Oct 2026
- Rotate Matrix Regions Around the DiagonalsOA · Seen Oct 2026
- Maximum Diamond SumOA · Seen Oct 2026
- Smallest Most-Lit Street PositionOA · Seen Oct 2026
- Rearrange String by Alternating EndsOA · Seen Sep 2026
- Most Items Within Budget from a Start IndexOA · Seen Sep 2026
- Count Fancy NumbersOA · Seen Sep 2026
- Count Pieces After Othello MovesOA · Seen Sep 2026
Similar questions at other companies
- Minimum Changes for Distinct Adjacent CharactersHeadlands Technologies · OAHeadlands Technologies interview questions
- Theme Park Shuttle Wait TimeAirbnb · OAAirbnb interview questions
- REST API: Country CodesHackerRank · OAHackerRank interview questions
- Fill One Exact-Length Binary WindowAmazon · OA
- Remove Vowels from a StringHSBC · OAHSBC interview questions
- Branch with the Most FilesCapital One · OACapital One interview questions
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Maximum Ones After K OperationsGoldman Sachs · OAGoldman Sachs interview questions
- Total Each Letter's Count in an Encoded StringIBM · OAIBM interview questions
- Robot Stops Left or Right (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions