ByteDance Intern Software Engineer Interview Experience — Four Difficult Online Assessment Questions

ByteDance·Software Engineer·Apr 2026
Online AssessmentInternmedium

There were four questions in total, and they were quite difficult.

Question 1

Description

Given an array of positive integers numbers, calculate how many of its elements have an even number of digits.

Note: The solution did not need to be optimal, but a time complexity no worse than O(numbers.length^2) would fit within the execution time limit.

Example

For numbers = [12, 134, 111, 1111, 10], the output should be solution(numbers) = 3.

  • numbers[0] = 12 has two digits, which is even.
  • numbers[1] = 134 has three digits, which is not even.
  • numbers[2] = 111 has three digits, which is not even.
  • numbers[3] = 1111 has four digits, which is even.
  • numbers[4] = 10 has two digits, which is even.

There are three elements, at indexes 0, 3, and 4, with an even number of digits, so the answer is 3.

Input and Output

Execution time limit: 4 seconds for Python 3.

Memory limit: 1 GB.

Input: array.integer numbers, an array of positive integers.

Guaranteed constraints: 1 <= numbers.length <= 1000 and 1 <= numbers[i] <= 10^4.

Output: integer.

Question 2

Description

You are given two integer arrays, nums1 and nums2, of the same length n. Consider every cyclic t-shift of nums1, where a shift moves t elements from the end to the front:

  • For t = 0: [nums1[0], nums1[1], nums1[2], ..., nums1[n - 1]]
  • For t = 1: [nums1[n - 1], nums1[0], nums1[1], ..., nums1[n - 2]]
  • For t = 2: [nums1[n - 2], nums1[n - 1], nums1[0], ..., nums1[n - 3]]
  • Continue this way through t = n - 1: [nums1[1], nums1[2], ..., nums1[n - 1], nums1[0]]

For every cyclic shift of nums1, calculate the sum of absolute differences with nums2. If the shifted array is numsShifted, the sum is:

|numsShifted[0] - nums2[0]| + |numsShifted[1] - nums2[1]| + ... + |numsShifted[n - 1] - nums2[n - 1]|

Return all of the sums sorted in non-descending order.

Note: The solution did not need to be optimal, but a time complexity no worse than O(nums1.length^3) would fit within the execution time limit.

Example

For nums1 = [1, 4, 2, 11] and nums2 = [10, 1, 8, 4], the output should be solution(nums1, nums2) = [7, 13, 25, 25].

The 0-shift is [1, 4, 2, 11]. Its sum is |1 - 10| + |4 - 1| + |2 - 8| + |11 - 4| = 9 + 3 + 6 + 7 = 25.

The 1-shift is [11, 1, 4, 2]. Its sum is |11 - 10| + |1 - 1| + |4 - 8| + |2 - 4| = 1 + 0 + 4 + 2 = 7.

The 2-shift is [2, 11, 1, 4]. Its sum is |2 - 10| + |11 - 1| + |1 - 8| + |4 - 4| = 8 + 10 + 7 + 0 = 25.

Question 3

Description

Given matrix, an n x m rectangular matrix of integers, define its 0-border as the union of its leftmost and rightmost columns and its top and bottom rows. A vector's 0-border is the vector itself.

If the matrix's 0-border is removed, the 0-border of the remaining matrix becomes the original matrix's 1-border. Repeating that process defines the 2-border, 3-border, and so on until reaching the center.

The visual representation of the 0-border, 1-border, and 2-border was omitted.

For every valid k, sort the elements in the k-border and place them clockwise in ascending order, starting from the top-left corner.

Note: The solution did not need to be optimal, but a time complexity no worse than O(n * m * (n + m)) would fit within the execution time limit.

Example input:

matrix = [
    [9, 7, -4, 5],
    [1, 6, 2, -6],
    [12, 20, 2, 0],
]

Question 4

Description

You are monitoring building density in a district of houses. The district is represented as a number line, with every house at an integer location. Some houses are gradually destroyed over time.

You are given houses, an array of integers representing the initial locations of all houses, and queries, an array of house locations in the order they will be destroyed. After each destruction, find the number of house segments remaining. A house segment is one or more adjacent houses with no house immediately adjoining either end.

Return an array containing the number of house segments after every house in queries is destroyed.

Every location in houses is distinct. Every location in queries occurs in houses, and the query locations are also distinct.

For houses = [1, 2, 3, 6, 7, 9] and queries = [6, 3, 7, 2, 9, 1], the output should be solution(houses, queries) = [3, 3, 2, 2, 1, 0].

Published

Curated and edited by PracHub

Practice the questions from this interview

Discussion

Sign in to join the discussion. The author is notified of every comment.

Loading comments…

Interview at a glance

Company
ByteDance
Role
Software Engineer
Level
Intern
Rounds
Online Assessment
Difficulty
medium
Interview date
Apr 2026
Questions from this interview
4 questions

Real ByteDance interview experiences

First-hand reports from ByteDance candidates — the rounds, the questions they were asked, and how it went.

All 32 ByteDance interview experiences