CS-OA cs-vo Faang

Meta VO record – meta 面经 – meta面试真题

meta的面试是非常标准的45分钟2道算法题,这次的算法题还有一些联动,我们一起来看看吧。

题目一:

There is a array of trips intervals, non-sorted, represented as a 2D integer array, each trip intervals within that array are 1D 2-element arrays consisting start time as first element, and end time as second element and has the following criteria:

  • Entire trip interval array can be empty
  • Bounds for number of trip intervals: 0 <= N <= 2^31
  • Bounds for trip timestamp value: 0 <= M <= 2^31
  • Within each trip interval, start time < end time
  • End time is exclusive when considering trips overlapping

Return if there are any overlapping trip intervals.

Examples:
[[1, 3], [2, 5]] -> true
[[1, 3], [3, 5]] -> false

题目要求我们判断一个由多个行程时间间隔组成的数组中是否存在重叠。这些行程间隔是以二维整数数组的形式表示的,每个行程间隔是一个一维数组,包含两个元素:起始时间和结束时间。结束时间是排他性的,即一个行程的结束时间与另一个行程的开始时间相同并不算作重叠。

具体要求

  • 行程间隔数组可以为空:如果数组为空,显然没有重叠。
  • 行程间隔数的范围:0≤𝑁≤2310≤N≤231。
  • 时间戳的范围:0≤𝑀≤2310≤M≤231。
  • 每个行程间隔内部:起始时间必须小于结束时间。
  • 结束时间排他性:结束时间与下一个行程的开始时间相同不算重叠。

解题思路

  1. 排序:首先根据每个行程的起始时间对行程间隔进行排序。这样,我们只需比较连续的行程间隔是否重叠。
  2. 比较相邻行程:遍历排序后的行程间隔数组,比较每个行程的结束时间与下一个行程的开始时间。如果当前行程的结束时间大于下一个行程的开始时间,则存在重叠。
  3. 返回结果:如果发现任何重叠,函数应返回 true。如果所有行程间隔都不重叠,函数返回 false

题目二:

There is a array of trips intervals, non-sorted, represented as a 2D integer array, each trip intervals within that array are 1D 2-element arrays consisting start time as first element, and end time as second element and has the following criteria:

  • Entire trip interval array can be empty
  • Bounds for number of trip intervals: 0 <= N <= 2^31
  • Bounds for trip timestamp value: 0 <= M <= 2^31
  • Within each trip interval, start time < end time
  • End time is exclusive when considering trips overlapping

Return the maximum concurrent trips at any given time.

结语

我们提供面试辅助,面试助攻,代面试,面试代面等服务。如果你也想在2024年的招聘中加入大厂,欢迎随时联系我们。

联系我 我们公开透明报价,做华人社区面试suport第一品牌。

Leave a Reply

Your email address will not be published. Required fields are marked *