字节跳动tiktok oa题目

更多资源与服务

想要了解更多编程面试技巧,或者需要专业的面试辅导OA代做简历润色等服务?我们提供全方位的求职面试支持,帮助您在大厂面试真题系统设计面试算法面试中脱颖而出,轻松拿到心仪的 offer!无论您是留学生、刚踏入职场的新人,还是需要代码优化建议的开发者,我们的团队由ACM奖牌得主、大厂资深 TLM 及经验丰富的行业老兵组成,确保为您提供最专业的指导。

扫描下方二维码,添加我们的微信,获取更多服务:

微信二维码

关键词:

  • 面试代面
  • 代码代写
  • OA代做
  • 面试技巧
  • 面试经验分享
  • 职业规划
  • 编程练习

让我们帮助您在技术面试中脱颖而出,实现职业上的飞跃!

Question 1: Finding Minimum Trips by TikRouter

Description:

Given a list of packet sizes, calculate the minimum number of trips required by the TikRouter to transport all packets. Each trip can carry up to a maximum size of 3.0 units.

Implement a function that sorts the packet sizes and calculates the minimum trips by combining the smallest and largest packets in each trip whenever possible.

Input:

  • packet_sizes (List[float]): List of packet sizes.

Output:

  • Returns an integer representing the minimum number of trips needed.

Code Example:

def findMinimumTripsByTikRouter(packet_sizes):
    packet_sizes.sort()
    t = 0
    i = 0
    j = len(packet_sizes) - 1
    while i <= j:
        if packet_sizes[i] + packet_sizes[j] <= 3.0:
            i += 1
        j -= 1
        t += 1
    return t

Question 2: Optimizing Storage by Cleaning

Description:

Given two lists of user content categories, for_you and following, implement a function to determine if any content category in the for_you list intersects with the corresponding category in the following list. Return "YES" if there is any intersection for that category index, otherwise return "NO".

This function helps in cleaning storage by identifying redundant content between two lists.

Input:

  • for_you (List[List[str]]): List of content categories for the "For You" section.
  • following (List[List[str]]): List of content categories for the "Following" section.

Output:

  • Returns a list of strings, "YES" or "NO", for each index indicating if there’s an overlap in categories.

Code Example:

def optimizeStorageByCleaning(for_you, following):
    res = []
    for a, b in zip(for_you, following):
        if set(a) & set(b):
            res.append("YES")
        else:
            res.append("NO")
    return res