FastPrepRemove CSS Comments and Find Hex Colors
Problems/Remove CSS Comments and Find Hex Colors

Remove CSS Comments and Find Hex Colors

Adobe logoAdobe● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks you to remove CSS comments and return the remaining text, plus the three- or six-digit hex colors. The report allows any order for the matches. Here, we sort them, and we put the text and the colors together in one array of strings. To clear up unclear cases, a color must be a whole token, comments are plain text, and the input is ASCII only.

Our version is about 95% the same as the reported question.

Remove every CSS comment from inputText. A comment starts with /* and ends at the next */. Copy all text outside the original comments exactly, including spaces and line breaks; do not insert replacement spaces or parse comment markers created by joining text.

In the resulting text, a color token begins with #. Read the entire following run of hexadecimal digits (0-9, a-f, A-F); keep the token only when that run has exactly three or six digits. Preserve letter case and repeated matches. A longer run must not contribute a shorter prefix.

Return a string array whose first entry is the modified text and whose remaining entries are all matched color tokens sorted in ascending, case-sensitive ASCII order. There may be no matches. Comment markers are recognized as plain text, even inside quotation marks.

Function

cssHexColorCodeMatcher(inputText: String) → String[]

Examples

Example 1

inputText = "a {color:#abc;} /* #000000 */"return = ["a {color:#abc;} ","#abc"]

Delete the complete comment, including its #000000. The space before the comment stays. The remaining color is #abc.

Example 2

inputText = "#a/*gone*/bc #1234 #AbCDef"return = ["#abc #1234 #AbCDef","#AbCDef","#abc"]

Removing the comment joins #a and bc into #abc. Reject #1234 because its full hexadecimal run has four digits. Both valid colors remain, with uppercase A sorting before lowercase a.

Constraints

  • 0 <= inputText.length < 25000.
  • For this exercise, assume inputText contains ASCII characters, with tab, carriage return and newline also allowed.
  • For this exercise, assume every /* opener has a following */ closer, and comments do not nest.

Source note: Original OA task images and any included source example. The practice contract follows the rules stated in the problem and source note.

More Adobe Online Assessment questions

  • Base Unit ConversionsOA · Seen Nov 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Top-Funded Villages and ProjectsOA · Seen Aug 2026
  • Count Parent Nodes With a Target SumOA · Seen Aug 2026
  • Largest Binary Number by ConcatenationOA · Seen Aug 2026
  • Count Events by CategoryOA · Seen Aug 2026
  • Graph M-ColoringOA · Seen Aug 2026
  • Hall of Shifting TilesOA · Seen Aug 2026
  • K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
  • Maze ReachabilityOA · Seen Aug 2026

Similar questions at other companies

  • Order LayoutAmazon · OA
  • Top K Movies by Play Count from CSV DataTubi · PHONE SCREEN
  • Transform Dotted Keys into a Nested MapProofpoint · ONSITE INTERVIEW
  • Serialize and Deserialize a String Key-Value StoreByteDance · ONSITE INTERVIEWByteDance interview questions
  • Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions
  • Parse and Order Structured LogsCoinbase · ONSITE INTERVIEWCoinbase interview questions
  • Rank Word-Translation Hints from Sentence TranslationsDuolingo · ONSITE INTERVIEWDuolingo interview questions
  • Deep Merge with a Conflict ResolverAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Common Words Across FilesMeta · PHONE SCREENMeta interview questions
  • Brazilian Receivables Part 3 — Partial ContractsStripe · PHONE SCREENStripe interview questions

Adobe interview experiences

  • Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience
  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
  • Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public String[] cssHexColorCodeMatcher(String inputText) {
        // Write your solution here.
    }

}
Checking account…