TikTok AMS (Algorithm & Machine Learning Systems) 2025 Campus Recruitment Assessment Latest Questions. oavoservice compiles complete questions and solutions to help you pass the screening.
📋 Question 1: Sliding Window Maximum
Given an array and window size k, return the maximum value in each window.
Solution: Monotonic Queue
from collections import deque
def maxSlidingWindow(nums, k):
if not nums or k == 0:
return []
dq = deque() # Stores indices
result = []
for i in range(len(nums)):
# Remove elements out of window
while dq and dq[0] < i - k + 1:
dq.popleft()
# Remove elements smaller than current element
while dq and nums[dq[-1]] < nums[i]:
dq.pop()
dq.append(i)
# Add result after window forms
if i >= k - 1:
result.append(nums[dq[0]])
return result
Time: O(n) Space: O(k)
📋 Question 2: String Encoding Compression
Implement Run-Length Encoding (RLE) for a string.
Solution
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
# Read number
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)
💼 How oavoservice Helps
Latest Real Questions - 2025 Campus Recruitment Questions Detailed Analysis - In-depth logic and code Time Management - OA answering strategy
Contact oavoservice for professional OA assistance!
Tags: #TikTok #AMS #CampusRecruitment #OA #SlidingWindow #OAHelp #InterviewPrep #1point3acres
Need real interview questions? Contact WeChat Coding0201 immediately to get real questions.