Snap | Coding questions | MLE role
Anonymous User
1331

Here are my coding interview questions with Snap:

Question 1

Your are assigned to support the following feature:

Given two sentences and one group of synonyms, decide if the two sentence share the same meaning.

For example
sent1 = "the photo is pretty"
sent2 = "the image is beautiful"
sent3 = "that photo is pretty"
groups_of_syns = [["photo", "image"], ["pretty", "amazing", "nice"], ["nice", "good-looking"], ["good-looking", "beautiful"]]

Should return True for sent1 and sent2, Should return False for sent1 and sent3

Question 2

Consider an undirected tree with n vertices (1 to n). We start from vertex 1, and start walking on the tree via steps. The rules for each step:

  • Previously visited vertices can not be visited again.
  • When multiple vertices are possible, each of them are equally likely.
  • If there are no possible vertices to move to, we are forced to take a dummy step from the current vertex to the current vertex.

What is the probability that we are at vertex k after s steps?

Input: edges: List[List[int, int]], k int, s int
Output: prob float

Comments (2)