Loading Now

overlapped

Given a string s and a dictionary d, find the number of pairs of words from the dictionary, whose occurrences in soverlap. Note, that two words can overlap more than once, and a word may overlap itself.

Example

  • For s = "knowledgeneralhellohellotestcase" and d = "knowledge", "general", "hello"], the output should be overlapped(s, d) = 1.

    In this example, "knowledge" and "general" overlaps.

  • For s = "iloveprogrammingenuityweneededginess" and d = ["programming", "ingenuity", "needed", "edginess"], the output should be overlapped(s, d) = 2.

    Here, "programming" overlaps with "ingenuity" and "needed" overlaps with "edginess".

Input/Output

  • [execution time limit] 0.5 seconds

  • [input] string s

    A string of lowercase English letters.

    Constraints:

    3 ≤ s.length ≤ 150.

  • [input] array.string d

    List of distinct words, where each word consists of lowercase English letters.

    Constraints:

    1 ≤ d.length ≤ 15,

    1 ≤ d[i] ≤ 15.

  • [output] integer

    • The number of pairs of words that overlap.

Post Comment

Contact