← Questions

Substring search and weighted random sampling

0
GoogleCodingLast asked Mar 2026

Two problems for a machine learning engineer screen:

  1. Find where a pattern occurs in a text, and discuss doing better than checking every position.
  2. Pick an item at random with probability proportional to its weight.
Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding