FastPrepRank Unseen Items by Embedding Similarity
Problems/Rank Unseen Items by Embedding Similarity

Rank Unseen Items by Embedding Similarity

Yahoo logoYahoo● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report specifies dot-product similarity, descending item-index ranking, and filtering out items the user has already seen. The exact tie rule, the array signature, examples, and limits are our fixed details. Our version is about 91% the same as the reported question.

You are given one user embedding and n item embeddings of the same dimension. The similarity of an item is the dot product of its embedding with the user embedding.

Exclude every item index in seenItemIndexes. Return all remaining item indices ordered from highest similarity to lowest. Break an exact score tie by the smaller item index.

Function

rankUnseenItems(userEmbedding: double[], itemEmbeddings: double[][], seenItemIndexes: int[]) → int[]

Examples

Example 1

userEmbedding = [1.0,2.0]itemEmbeddings = [[1.0,0.0],[0.0,2.0],[2.0,1.0],[-1.0,0.0]]seenItemIndexes = [1]return = [2,0,3]

After excluding item 1, the dot products are 4, 1, and -1 for indices 2, 0, and 3.

Example 2

userEmbedding = [1.0,1.0]itemEmbeddings = [[2.0,0.0],[0.0,2.0],[1.0,1.0]]seenItemIndexes = []return = [0,1,2]

All three scores are 2, so indices determine the order.

Constraints

  • 1 <= itemEmbeddings.length <= 100000.
  • 1 <= userEmbedding.length <= 200, and every item embedding has that length.
  • All coordinates are finite doubles with absolute value at most 10^6.
  • Seen indices are distinct and valid.

More Yahoo interview questions

  • Logistic Regression with Gradient DescentPHONE SCREEN · Seen Nov 2026
  • Count Binary SubstringsOA · Seen Mar 2025
  • Modify the StringOA · Seen Mar 2025

Similar questions at other companies

  • Majority ElementByteDance · PHONE SCREENByteDance interview questions
  • Recommend Films from Viewers Who Watched Everything You DidBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Total Years of Work ExperienceLinkedIn · PHONE SCREENLinkedIn interview questions
  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN
  • Squares of a Sorted ArrayInstacart · PHONE SCREENInstacart interview questions
  • Assign CookiesAmazon · PHONE SCREEN
  • Sort by Checking PermutationsMercor · PHONE SCREENMercor interview questions
  • Meeting RoomsGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • Parse and Sort Integer DataLegora · PHONE SCREEN

Yahoo interview experiences

  • Yahoo Mail Senior MLE Interview Experience: 1 Experience
All Yahoo interview questionsSee Yahoo hiring insights
Saved
class Solution {
    public int[] rankUnseenItems(double[] userEmbedding, double[][] itemEmbeddings, int[] seenItemIndexes) {
        // Write your code here.
    }
}
Checking account…