TERRA Hiring | Off-Campus OA (2025) | Count Items Matching a Rule

Question · Posted Jun 2026

Problem Statement You are given a 2D list items where each item is represented as: type color name You are also given: ruleKey ruleValue Return the number of items whose value corresponding to ruleKey equals ruleValue. Example Input: items = [["phone","blue","pixel"],          ["computer","silver","lenovo"],          ["phone","gold","iphone"]] ruleKey = "color" ruleValue = "silver" Output: 1 Explanation: Only the second item has color "silver".

The full answer & interview discussion are available to premium members.

Log in Create a free account