← 返回博客列表
TikTok

TikTok AMS 2025 校招评估真题分享

2025-10-24

TikTok AMS(Algorithm & Machine Learning Systems025 校招评估最新真题csvosupport* 整理完整题目和解法,助你顺利通过筛选

📋 题目一:滑动窗口最大

给定数组和窗口大k,返回每个窗口的最大值

解法:单调队

from collections import deque

def maxSlidingWindow(nums, k):
    if not nums or k == 0:
        return []
    
    dq = deque()  # 存储索引
    result = []
    
    for i in range(len(nums)):
        # 移除窗口外的元素
        while dq and dq[0] < i - k + 1:
            dq.popleft()
        
        # 移除比当前元素小的元
        while dq and nums[dq[-1]] < nums[i]:
            dq.pop()
        
        dq.append(i)
        
        # 窗口形成后添加结
        if i >= k - 1:
            result.append(nums[dq[0]])
    
    return result

*时间 O(n) *空间 O(k)

📋 题目二:字符串编码压

实现字符串的游程编码(Run-Length Encoding)

解法

def encode(s):
    if not s:
        return ""
    
    result = []
    count = 1
    
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            count += 1
        else:
            result.append(s[i-1] + str(count))
            count = 1
    
    result.append(s[-1] + str(count))
    encoded = ''.join(result)
    
    return encoded if len(encoded) < len(s) else s

def decode(s):
    result = []
    i = 0
    
    while i < len(s):
        char = s[i]
        i += 1
        
        # 读取数字
        num_str = ''
        while i < len(s) and s[i].isdigit():
            num_str += s[i]
            i += 1
        
        count = int(num_str)
        result.append(char * count)
    
    return ''.join(result)

💼 csvosupport 助力

*最新真 - 2025 校招题目 完整解析 - 详细思路和代 时间管理 - OA 答题策略

联系 csvosupport,专OA 辅助服务


*标签 #TikTok #AMS #2025校招 #OA #滑动窗口 #OA代做 #面试辅助 #一亩三分地


需要面试真题? 立刻联系微信 Coding0201,获得真题