text: """
  https://leetcode.com/problems/substring-with-concatenation-of-all-words/
  """
  from typing import List
  
  
  class Solution:
      def findSubstring(self, s: str, words: List[str]) -> List[int]:
          result = []
          wordMap = {}
          l = 0
          n = 0
          for word in words:
              l = len(word)
              n += 1
              if word in wordMap:
                  wordMap[word] += 1
              else:
                  wordMap[word] = 1
          i = 0
          while i < len(s):
              j = i
              tmpMap = wordMap.copy()
              tmpN = n
              while j < len(s):
                  step = 1
                  w = s[j:j+l]
                  if w in tmpMap and tmpMap[w] > 0:
                      tmpMap[w] -= 1
                      tmpN -= 1
                      if tmpN == 0:
                          result.append(i)
                      step = l
                  else:
                      break
                  j += step
              i += 1
          return result
  