Lucid Motors Interview Questions
Showing 9 questions
Imagine a tree where some nodes have coins. You want to collect all the coins, but you can only traverse the tree. Find the minimum number of edges you need to travel to collect all the coins.
#1. Collect Coins in a Tree
You have a range of numbered balls to distribute into boxes. A ball goes into a box based on the sum of its digits, so find the box that ends up with the most balls.
#2. Maximum Number of Balls in a Box
Determine if a string containing parentheses is valid. A valid string has matching and properly nested opening and closing parentheses.
#3. Valid Parentheses
You are given a circular route with gas stations. Determine if you can complete the circuit, starting from a particular station, given the gas available and cost to travel between stations.
#4. Gas Station
Given a number 'n', generate all possible well-formed (balanced) parentheses strings of length 2*n. For instance, if n=3, you need to create all valid combinations like '((()))', '(()())', etc.
#5. Generate Parentheses
Find the length of the longest substring within a given string that contains no repeating characters. The substring must be contiguous.
#6. Longest Substring Without Repeating Characters
Given a grid representing land and water, count the number of distinct islands. An island is formed by connected land cells.
#7. Number of Islands
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. You need to implement a stack with an additional function to efficiently get the minimum value.
#8. Min Stack
Find the lowest common ancestor of two nodes in a given binary tree. The lowest common ancestor is defined as the farthest node from the root that is an ancestor of both nodes.
#9. Lowest Common Ancestor of a Binary Tree