Interview Questions

Review this list of 4,065 interview questions and answers verified by hiring managers and candidates.
  • +4

    "Using a DFS approach, computing all the distances from typing import List from collections import deque def shortestCellPath(grid: List[List[int]], sr: int, sc: int, tr: int, tc: int) -> int: if sr == tr and sc == tc: return 0 nRows = len(grid) nCols = len(grid[0]) distances = [] stack = deque([(sr, sc, 0)]) visitedSet = set() while stack: nodeR, nodeC, nodeDist = stack.pop() if gridnodeR == 0 or (nodeR, nodeC) in visited"

    Gabriele G. - "Using a DFS approach, computing all the distances from typing import List from collections import deque def shortestCellPath(grid: List[List[int]], sr: int, sc: int, tr: int, tc: int) -> int: if sr == tr and sc == tc: return 0 nRows = len(grid) nCols = len(grid[0]) distances = [] stack = deque([(sr, sc, 0)]) visitedSet = set() while stack: nodeR, nodeC, nodeDist = stack.pop() if gridnodeR == 0 or (nodeR, nodeC) in visited"See full answer

    Data Structures & Algorithms
    Coding
  • Sales Path

    IDE
    Medium
    +6

    "def getcheapestcost(rootNode): \# need to do DFS for each branch \# but this can be done recursively n = len(rootNode.children) if n == 0: return 0 else: min_cost = float('inf') for i in range(len(n)): tempcost = getcheapest_cost(rootNode.children[i]) if (tempcost < mincost): mincost = tempcost return min_cost + rootNode.cost \# A node class Node: \# Constructor to create a new node def init\(self, cost): self.cost = cost self.children = [] self.parent = None"

    Anonymous Owl - "def getcheapestcost(rootNode): \# need to do DFS for each branch \# but this can be done recursively n = len(rootNode.children) if n == 0: return 0 else: min_cost = float('inf') for i in range(len(n)): tempcost = getcheapest_cost(rootNode.children[i]) if (tempcost < mincost): mincost = tempcost return min_cost + rootNode.cost \# A node class Node: \# Constructor to create a new node def init\(self, cost): self.cost = cost self.children = [] self.parent = None"See full answer

    Data Structures & Algorithms
    Coding
  • +3

    "def flatten_dictionary(dictionary): \# return a flattened dictionary - int/string/another dictionary values \# if the key is empty, exclude from the output \# concat using a "." btwn them \# add to res which is { "key.a.b.etc": "value" } \# iterate through the key value pairs \# while there is a key value pair in the value \# continue going through that, until the value is an int/string flatDic = {} flatDicHelper("", dictionary, flatDic) print(flatDic) return flatDic def flatDicHelper(initialKey"

    Anonymous Owl - "def flatten_dictionary(dictionary): \# return a flattened dictionary - int/string/another dictionary values \# if the key is empty, exclude from the output \# concat using a "." btwn them \# add to res which is { "key.a.b.etc": "value" } \# iterate through the key value pairs \# while there is a key value pair in the value \# continue going through that, until the value is an int/string flatDic = {} flatDicHelper("", dictionary, flatDic) print(flatDic) return flatDic def flatDicHelper(initialKey"See full answer

    Data Structures & Algorithms
    Coding
  • +37

    "Here's a simpler solution: select u.username , count(p.postid) as countposts from posts as p join users as u on p.userid = u.userid where p.likes >= 100 group by 1 order by 2 desc, 1 asc limit 3 `"

    Bradley E. - "Here's a simpler solution: select u.username , count(p.postid) as countposts from posts as p join users as u on p.userid = u.userid where p.likes >= 100 group by 1 order by 2 desc, 1 asc limit 3 `"See full answer

    Data Engineer
    Coding
    +3 more
  • +14

    "The unique id is not clear in this question"

    Anonymous Possum - "The unique id is not clear in this question"See full answer

    Coding
    SQL
  • 🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.

  • +17

    "`select employeeid, employeename, sum(maxscore) totalscore from ( select e.id employeeid, e.name employeename, tr.testid , max(tr.score) maxscore from employees e join test_results tr on e.id = tr.employee_id group by tr.employeeid, tr.testid order by 1 ) group by 1,2 order by 3 desc` `"

    Abbas M. - "`select employeeid, employeename, sum(maxscore) totalscore from ( select e.id employeeid, e.name employeename, tr.testid , max(tr.score) maxscore from employees e join test_results tr on e.id = tr.employee_id group by tr.employeeid, tr.testid order by 1 ) group by 1,2 order by 3 desc` `"See full answer

    Data Engineer
    Coding
    +3 more
  • +20

    "SELECT pro.id, pro.title, pro.budget, COUNT(employeeid) AS numemployees, SUM(e.salary) as total_salaries FROM projects pro JOIN employeesprojects ep ON ep.projectid = pro.id JOIN employees e ON e.id = ep.employee_id GROUP BY project_id; `"

    Zacharias E. - "SELECT pro.id, pro.title, pro.budget, COUNT(employeeid) AS numemployees, SUM(e.salary) as total_salaries FROM projects pro JOIN employeesprojects ep ON ep.projectid = pro.id JOIN employees e ON e.id = ep.employee_id GROUP BY project_id; `"See full answer

    Coding
    SQL
  • +25

    "SELECT d.name as departmentname,e.id as employeeid,e.firstname,e.lastname,MAX(e.salary) as salary FROM employees e LEFT JOIN departments d ON e.department_id=d.id GROUP BY department_name ORDER BY department_name;"

    Anisha S. - "SELECT d.name as departmentname,e.id as employeeid,e.firstname,e.lastname,MAX(e.salary) as salary FROM employees e LEFT JOIN departments d ON e.department_id=d.id GROUP BY department_name ORDER BY department_name;"See full answer

    Data Engineer
    Coding
    +3 more
  • +50

    "Limit and rank() only works if there are no 2 employees with same salary ( which is okay for this use case) For the query to pass all the test results, we need to use dense_rank with ranked_employees as ( select id, firstname, lastname, salary, denserank() over(order by salary desc) as salaryrank from employees ) select id, firstname, lastname, salary from ranked_employees where salary_rank <= 3 `"

    Vysali K. - "Limit and rank() only works if there are no 2 employees with same salary ( which is okay for this use case) For the query to pass all the test results, we need to use dense_rank with ranked_employees as ( select id, firstname, lastname, salary, denserank() over(order by salary desc) as salaryrank from employees ) select id, firstname, lastname, salary from ranked_employees where salary_rank <= 3 `"See full answer

    Data Engineer
    Coding
    +3 more
  • +20

    "select name, stock from products p left join transactions t on p.id = t.product_id order by date desc limit 1"

    Daniel C. - "select name, stock from products p left join transactions t on p.id = t.product_id order by date desc limit 1"See full answer

    Data Engineer
    Coding
    +3 more
  • +13

    "I'm pretty sure Exponent's answer is wrong. In the snippet below, they use "pl.name = 'Telephones' to attempt to filter down to the Telephone transactions, but they do this within a LEFT JOIN which means all product_lines rows are returned. > LEFT JOIN product_lines pl > ON p.productlineid = pl.id > AND pl.name = 'Telephones' Below is my solution. Also, I didn't see anywhere that said the "amount" column was in cents instead of dollars, but I still divided by 100 to be consistent with Exp"

    Bradley E. - "I'm pretty sure Exponent's answer is wrong. In the snippet below, they use "pl.name = 'Telephones' to attempt to filter down to the Telephone transactions, but they do this within a LEFT JOIN which means all product_lines rows are returned. > LEFT JOIN product_lines pl > ON p.productlineid = pl.id > AND pl.name = 'Telephones' Below is my solution. Also, I didn't see anywhere that said the "amount" column was in cents instead of dollars, but I still divided by 100 to be consistent with Exp"See full answer

    Coding
    SQL
  • +12

    "--country names are UPPERCASE but the table in the in the question showing lowercase. That's why it took me a while to figure it out until I ran the country column WITH RECURSIVE Hierarchy AS ( SELECT e.Emp_ID, CONCAT(e.FirstName, ' ', e.MiddleName, ' ', e.LastName) AS FullName, e.Manager_ID, 0 AS Level, CASE WHEN e.Country = 'IRELAND' THEN s.Salary * 1.09 WHEN e.Country = 'INDIA' THEN s.Salary * 0.012 ELSE s.Salary "

    Victor N. - "--country names are UPPERCASE but the table in the in the question showing lowercase. That's why it took me a while to figure it out until I ran the country column WITH RECURSIVE Hierarchy AS ( SELECT e.Emp_ID, CONCAT(e.FirstName, ' ', e.MiddleName, ' ', e.LastName) AS FullName, e.Manager_ID, 0 AS Level, CASE WHEN e.Country = 'IRELAND' THEN s.Salary * 1.09 WHEN e.Country = 'INDIA' THEN s.Salary * 0.012 ELSE s.Salary "See full answer

    Data Engineer
    Coding
    +3 more
  • Meta (Facebook) logoAsked at Meta (Facebook) 
    +11

    "Interviewer: Design a Meta Product for space travel. Me: I would first likely ask a few clarifying questions. Can we discuss more about what do we mean by a product for space travel? Is it like a physical product or a software product? Any existing suite of products that we want to integrate this into? Interviewer: It can be a digital platform – a combination of software and services, integrated in a single ecosystem. It's not a physical product like a spacecraft, but rather a pla"

    Ankit M. - "Interviewer: Design a Meta Product for space travel. Me: I would first likely ask a few clarifying questions. Can we discuss more about what do we mean by a product for space travel? Is it like a physical product or a software product? Any existing suite of products that we want to integrate this into? Interviewer: It can be a digital platform – a combination of software and services, integrated in a single ecosystem. It's not a physical product like a spacecraft, but rather a pla"See full answer

    Product Manager
    Product Design
  • LinkedIn logoAsked at LinkedIn 
    Software Engineer
    Data Structures & Algorithms
    +1 more
  • Product Designer
    Product Design
  • +4

    "Clarifications: Where are we launching? -- US first 1:1 or n:n video conferencing? -- you assume Consumers or Business? -- consumers Part of FB or standalone product? -- part of messenger app Is it MVP launch or a full feature product? -- MVP What capabilities exist in the video conference product? -- you assume what capabilities will be > Trends and Markets Competitors: Consumer Zoom Google Meet Business: Slack MS Teams Trends: More and more people are usi"

    Aniket A. - "Clarifications: Where are we launching? -- US first 1:1 or n:n video conferencing? -- you assume Consumers or Business? -- consumers Part of FB or standalone product? -- part of messenger app Is it MVP launch or a full feature product? -- MVP What capabilities exist in the video conference product? -- you assume what capabilities will be > Trends and Markets Competitors: Consumer Zoom Google Meet Business: Slack MS Teams Trends: More and more people are usi"See full answer

    Product Manager
    Execution
    +1 more
  • Meta (Facebook) logoAsked at Meta (Facebook) 
    Product Manager
    Product Design
  • Product Manager
    Analytical
    +1 more
  • Disney logoAsked at Disney 
    Product Manager
    Behavioral
Showing 1721-1740 of 4065