Ebay计算机科学面试真题

职位分类
全部
数据相关
计算机科学
人工智能
产品经理
BQ
面试题
全部(73)
OOD(3)
Algorithm(60)
System Design(4)
高频题(0)
Math(0)
全部(73)
OOD(3)
Algorithm(60)
System Design(4)
高频题(0)
Math(0)
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.Optimization of String Transformation
28.Pattern Matching in a Dictionary of Words
29.Handling Stream Input for a Coding Problem
30.Calendar Meeting Scheduling
31.System Design for a TinyURL Service
32.Longest Substring Without Repeating Characters
33.Topological Sorting of Course Schedule
34.Count Islands in a Grid
35.Object-Oriented Design of a Shopping Cart
36.Design a Hash Map
37.Algorithm and Complexity Analysis Interview Question
38.Inheritance and Encapsulation Interview Question
39.Multithread and OOD Interview Question
40.Minimum Dial Turns to Reach New Time
41.Generate All Substrings of a String
42.System Design for an eBay Notification System
43.Climbing Stairs Problem
44.Convert a Linked List to a Binary Tree
45.Merge K Sorted Lists
46.Merge Intervals
47.String Skeleton Match
48.Game Winner Prediction
49.Boolean Expression Evaluation
50.Binary String Operations
51.Convert Snake Case to Camel Case
52.Ranking Players Based on Points and Score Differences
53.Find the Index of the First Local Minimum in an Array
54.Stone Game Variant
55.Array Transformation Algorithm
56.Circular Storage Operations
57.Street Light Coverage Problem
58.String Addition and Concatenation
59.Longest Subarray with Absolute Difference Constraint
60.Matrix Division to Minimize Max-Min Value Difference
61.Cyclic X-Shift Array to Reverse-Sorted Array
62.Longest Subarray with Limited Difference
63.Matrix Division to Minimize Maximal and Minimal Value Difference
64.Cyclic X-Shift Array
65.Rectangles Fit in a Large Rectangle
66.Building Houses at Specific Indices with Constraints
67.Circular Storage with a Starting Index
68.Word Formation from Characters with Hyphens
69.Find Elements Greater Than Neighbors in an Array
70.Binary String Operations
71.Convert Snake Case to Camel Case in Quoted Strings
72.Sum of First Positive Numbers and Subsequent Operations
73.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