Ebay计算机科学面试真题

职位分类
全部
数据相关
计算机科学
人工智能
产品经理
BQ
面试题
全部(81)
OOD(3)
Algorithm(63)
System Design(7)
高频题(0)
Math(1)
全部(81)
OOD(3)
Algorithm(63)
System Design(7)
高频题(0)
Math(1)
1.Coin Change Problem
2.Course Schedule II
3.Grouping Anagrams from a List of Strings
4.Unique Binary Search Trees Count
5.Validating Binary Search Tree
6."Finding Maximum Depth of a Binary Tree"
7.HasPathSum in Binary Tree
8.Search 2D Matrix
9.Finding the Lowest Common Ancestor of Two Nodes in a Binary Tree
10.Binary Tree Level Order Traversal
11.Finding the Lowest Common Ancestor in a Binary Search Tree
12.Search in Rotated Sorted Array
13.Wildcard Pattern Matching Algorithm
14.Matrix
15.Interval overlapping
16.Best Time to Buy and Sell Stock
17.‌‌‌‌‍‍‍‍‍‌‌‌‌‍‍‌‍Event Emitter
18.Fit With Cell Replacement
19.Reduce The Number
20.三角形水杯乘酒的问题
21.Rotating a Box and Simulating Gravity
22.Matrix Queries
23.New Text Editor
24."Remove Anagrams and Convert Binary Search Tree to Sorted Doubly Linked List"
25.Remove Duplicates from Sorted Array
26.光线覆盖问题
27.Fibonacci Number Optimization
28.Optimizing Search Engine Relevance
29.Serialize and Deserialize Binary Tree
30.C++ Profiling Tools
31.System Design for Finding Top K Similar Vectors
32.Simple Coding with Binary Search Follow-up
33.System Design - WebSocket vs Long Polling
34.Math Problem Related to Finding Common Multiples
35.Optimization of String Transformation
36.Pattern Matching in a Dictionary of Words
37.Handling Stream Input for a Coding Problem
38.Calendar Meeting Scheduling
39.System Design for a TinyURL Service
40.Longest Substring Without Repeating Characters
41.Topological Sorting of Course Schedule
42.Count Islands in a Grid
43.Object-Oriented Design of a Shopping Cart
44.Design a Hash Map
45.Algorithm and Complexity Analysis Interview Question
46.Inheritance and Encapsulation Interview Question
47.Multithread and OOD Interview Question
48.Minimum Dial Turns to Reach New Time
49.Generate All Substrings of a String
50.System Design for an eBay Notification System
51.Climbing Stairs Problem
52.Convert a Linked List to a Binary Tree
53.Merge K Sorted Lists
54.Merge Intervals
55.String Skeleton Match
56.Game Winner Prediction
57.Boolean Expression Evaluation
58.Binary String Operations
59.Convert Snake Case to Camel Case
60.Ranking Players Based on Points and Score Differences
61.Find the Index of the First Local Minimum in an Array
62.Stone Game Variant
63.Array Transformation Algorithm
64.Circular Storage Operations
65.Street Light Coverage Problem
66.String Addition and Concatenation
67.Longest Subarray with Absolute Difference Constraint
68.Matrix Division to Minimize Max-Min Value Difference
69.Cyclic X-Shift Array to Reverse-Sorted Array
70.Longest Subarray with Limited Difference
71.Matrix Division to Minimize Maximal and Minimal Value Difference
72.Cyclic X-Shift Array
73.Rectangles Fit in a Large Rectangle
74.Building Houses at Specific Indices with Constraints
75.Circular Storage with a Starting Index
76.Word Formation from Characters with Hyphens
77.Find Elements Greater Than Neighbors in an Array
78.Binary String Operations
79.Convert Snake Case to Camel Case in Quoted Strings
80.Sum of First Positive Numbers and Subsequent Operations
81.Find Elements Greater Than Neighbors
1. Coin Change Problem
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.

You may assume that you have an infinite number of each kind of coin.

 

Example 1:

Input: coins = [1,2,5], amount = 11
Output: 3
Explanation: 11 = 5 + 5 + 1

Example 2:

Input: coins = [2], amount = 3
Output: -1

Example 3:

Input: coins = [1], amount = 0
Output: 0

 

Constraints:

  • 1 <= coins.length <= 12
  • 1 <= coins[i] <= 231 - 1
  • 0 <= amount <= 104
2. Course Schedule II
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai.

  • For example, the pair [0, 1], indicates that to take course 0 you have to first take course 1.
Return the ordering of courses you should take to finish all courses. If there are many valid answers, return any of them. If it is impossible to finish all courses, return an empty array.

 

Example 1:

Input: numCourses = 2, prerequisites = [[1,0]]
Output: [0,1]
Explanation: There are a total of 2 courses to take. 
To take course 1 you should have finished course 0. So the correct course order is [0,1].

Example 2:

Input: numCourses = 4, prerequisites = [[1,0],[2,0],[3,1],[3,2]]
Output: [0,2,1,3]
Explanation: There are a total of 4 courses to take. To take course 3 you should have finished both courses 1 and 2.
Both courses 1 and 2 should be taken after you finished course 0.
So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3].

Example 3:

Input: numCourses = 1, prerequisites = []
Output: [0]

 

Constraints:

  • 1 <= numCourses <= 2000
  • 0 <= prerequisites.length <= numCourses * (numCourses - 1)
  • prerequisites[i].length == 2
  • 0 <= ai, bi < numCourses
  • ai != bi
  • All the pairs [ai, bi] are distinct.
3. Grouping Anagrams from a List of Strings
Given an array of strings strs, group the anagrams together. You can return the answer in any order.

An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.

 

Example 1:

Input: strs = ["eat","tea","tan","ate","nat","bat"]
Output: [["bat"],["nat","tan"],["ate","eat","tea"]]

Example 2:

Input: strs = [""]
Output: [[""]]

Example 3:

Input: strs = ["a"]
Output: [["a"]]

 

Constraints:

  • 1 <= strs.length <= 104
  • 0 <= strs[i].length <= 100
  • strs[i] consists of lowercase English letters.
4. Unique Binary Search Trees Count
给你一个整数 n ,求恰由 n 个节点组成且节点值从 1 到 n 互不相同的 二叉搜索树 有多少种?返回满足题意的二叉搜索树的种数。

 

示例 1:


输入:n = 3
输出:5
示例 2:

输入:n = 1
输出:1
 

提示:
1 <= n <= 19
5. Validating Binary Search Tree
Given the root of a binary tree, determine if it is a valid binary search tree (BST).

A valid BST is defined as follows:

  • The left subtree of a node contains only nodes with keys less than the node's key.
  • The right subtree of a node contains only nodes with keys greater than the node's key.
  • Both the left and right subtrees must also be binary search trees.
 

Example 1:

Input: root = [2,1,3]
Output: true

Example 2:

Input: root = [5,1,4,null,null,3,6]
Output: false
Explanation: The root node's value is 5 but its right child's value is 4.

 

Constraints:

  • The number of nodes in the tree is in the range [1, 104].
  • -231 <= Node.val <= 231 - 1