TikTok logo

TikTok

Culver City, CASocial Media

Interview Questions

Server Cost Optimization

Asked at TikTok
technical
algorithms
optimization

Calculate minimum cost for server purchases with special offer.

Problem: Given n servers with prices, apply special offer (half price) to one server to minimize total cost.

Example: Input:

  • n = 3
  • prices = [1, 4, 1]

Process:

  1. Apply offer to second server: [1, 2, 1]
  2. Calculate cost: |1-2| + |2-1| = 2

Requirements:

  • Handle all possible offer applications
  • Calculate minimum total cost
  • Consider adjacent server price differences

TikTok SWE Online Assessment (11.20-11.24)

Asked at TikTok
technical
algorithms
data structures
oa
TikTok OA Part 1 TikTok OA Part 2 TikTok OA Part 3 TikTok OA Part 4 TikTok OA Part 5 TikTok OA Part 6 TikTok OA Part 7 TikTok OA Part 8

Share Your Experience at TikTok