Assume we have a Node class with: int val Node right Node left Input: binary tree of ints (you’ll be given root node) Return the boundary traversal of t…
Given a string s consisting of lowercase English characters, determine if you can make it a palindrome by removing at most one letter. Example 1: Input:…
A multiset (also known as a bag) is a mutable, unordered collection of distinct objects that may appear more than once in the collection. Implement a mu…
Write a function that calculates the dot product of two vectors. 96% of vector components are zero. What is a good data structure for v1 , v2 so that yo…
Given a sequence of integers and an integer total target, return whether a continuous sequence of integers sums up to target. Example: [1, 3, 1, 4, 23],…
Find all palindromes in a string. 这道题要求在一个字符串中找出所有回文串,核心通常是枚举每一个可能的回文中心,并向两边扩展检查,这样可以同时处理奇数长度和偶数长度的回文。也可以结合动态规划或 Manacher 算法来进一步优化,但面试中最常见、最稳妥的方法是中心扩展:对…
Given a string containing characters ( and ) , find the length of the longest valid parentheses substring. 这道题要求在只包含左括号和右括号的字符串中,找出最长的有效括号子串长度。常见做法是使用栈来…
Given an array of integers, return the index of one of the largest elements, chosen uniformly at random. Example: index: 0 1 2 3 4 5 6 array: [5, 3, 6,…
Given an array of integers nums and an integer k , return the total number of subarrays whose sum equals k . A subarray is a contiguous non-empty sequen…
Given a string containing uppercase characters A-Z, remove pairs of adjacent characters if they are consecutive characters in the alphabet (for example,…
The input is a string containing open and close parentheses. Find the minimum number of parentheses that need to be added in order to balance the input…
Given a grid of land heights. For example: start 6 5 4 5 5 4 2 5 1 1 5 5 2 1 5 2 3 2 4 4 5 4 5 5 6 end The upper-left corner is the start cell, and the…
Given an integer, swap at most one pair of digits to make the largest possible integer. Example: 43183 -> 83143 Swap 4 and 8. 这道题要求你只允许交换一次数字中的一对位置,使结果尽…
Write a query to find the total value of sales and the number of unique paying customers, grouped and sorted in descending order by payment type. Existi…
Write a function that returns the smallest nonnegative number which can be generated by using all the digits with odd values of a given number. Example:…
This set of SQL interview questions uses a bookstore database with the following tables: books , authors , transactions , and customers . books book_id…
Meta VO Interview Question: Carpooling Value Proposition, Metrics, and Data Model Design A ride-share service allows customers to use an app to request…
Given a binary tree (pointer to the root), a target node anywhere in the tree, and an integer value K , return a list of the values of all the nodes tha…