FastPrepDetect a Keyword Substring
Problems/Detect a Keyword Substring

Detect a Keyword Substring

Amazon logoAmazon● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amazon full-time onsite interview. The report asks whether a keyword appears as a substring, but does not say how to clean up the text before matching or what to do with an empty list. Our version is about 94% the same as the reported question.

Given a string text and an array of nonempty keywords, return true when at least one keyword occurs as a contiguous substring of text.

For this exercise, assume matching is case-sensitive and literal. An empty keyword array produces false.

Function

containsKeyword(text: String, keywords: String[]) → boolean

Examples

Example 1

text = "distributed systems interview"keywords = ["system","database"]return = true

The keyword system occurs inside systems.

Example 2

text = "Cloud"keywords = ["cloud","database"]return = false

Matching is case-sensitive, so cloud does not match Cloud.

Constraints

  • 0 <= text.length <= 10^5
  • 0 <= keywords.length <= 10^4
  • 1 <= keywords[i].length <= 10^4
  • The total keyword length is at most 10^5.

More Amazon Onsite Interview questions

  • Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Cheapest Flights Within K StopsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dungeon GameONSITE INTERVIEW · Seen Nov 2026
  • Integer BreakONSITE INTERVIEW · Seen Nov 2026
  • LFU CacheONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Count Adjacent Symbol Pairs for BPEONSITE INTERVIEW · Seen Nov 2026
  • First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Valid ParenthesesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Longest Spoken PrefixElevenLabs · ONSITE INTERVIEWElevenLabs interview questions
  • Palindrome Check Ignoring SymbolsWalmart · ONSITE INTERVIEWWalmart interview questions
  • Reverse a String Keeping Dashes in PlaceNykaa · ONSITE INTERVIEWNykaa interview questions
  • Implement tail -nConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • Valid ParenthesesEPAM · ONSITE INTERVIEWEPAM interview questions
  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Bounded Word Guess SolverAtlassian · ONSITE INTERVIEWAtlassian interview questions
  • Filter Pins by Excluded IDsPinterest · ONSITE INTERVIEWPinterest interview questions

Interview reports that mention this question

  • Amazon SDE II Onsite and L5 Screens: 7 Experiences (Part 2 of 2)
  • Amazon SDE II OA and Interviews: 10 Experiences (Part 1 of 2)

Amazon interview experiences

  • Amazon SWE OA with AI Coding: 1 Experience
  • Amazon SWE Intern Phone Screen Interview Experience: 1 Experience
  • Amazon New Grad SDE I OA and Virtual Onsite: 1 Experience
  • Amazon BIE Intern SQL and Interview Questions: 17 Experiences
See Amazon hiring insights
Saved
class Solution {
    public boolean containsKeyword(String text, String[] keywords) {
        // Your code here
    }
}
Checking account…