PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/TikTok

Solve grid min path and sqrt by binary search

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in dynamic programming and algorithm design for grid-based path optimization as well as numerical methods and binary search for square-root approximation, encompassing time/space complexity analysis, external-memory handling for very large matrices, overflow avoidance, and numerical stability.

  • Medium
  • TikTok
  • Coding & Algorithms
  • Software Engineer

Solve grid min path and sqrt by binary search

Company: TikTok

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

1) Given an m x n matrix of non-negative integers, find a path from the top-left to the bottom-right that minimizes the sum of cell values. You may only move right or down. Return both the minimum sum and one optimal path. Describe the algorithm, justify correctness, and analyze time/space complexity. Consider how to handle very large matrices that do not fit entirely in memory. 2) Implement sqrt(x) using binary search. - Version A: return floor(sqrt(x)) for a non-negative 32-bit or 64-bit integer x without using built-in square root functions; avoid overflow and analyze complexity. - Version B: return a double approximation within 1e-6 for a non-negative real x; discuss stopping conditions, numerical stability, and edge cases (x=0, 0<x<1, very large x).

Quick Answer: This question evaluates proficiency in dynamic programming and algorithm design for grid-based path optimization as well as numerical methods and binary search for square-root approximation, encompassing time/space complexity analysis, external-memory handling for very large matrices, overflow avoidance, and numerical stability.

Related Interview Questions

  • Parse a nested list from a string - TikTok (medium)
  • Implement stacks, streaming median, and upward path sum - TikTok (easy)
  • Maximize sum with no adjacent elements - TikTok (medium)
  • Implement stack variants and path-sum check - TikTok (medium)
  • Find the longest palindromic substring - TikTok (easy)
TikTok logo
TikTok
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0
  1. Given an m x n matrix of non-negative integers, find a path from the top-left to the bottom-right that minimizes the sum of cell values. You may only move right or down. Return both the minimum sum and one optimal path. Describe the algorithm, justify correctness, and analyze time/space complexity. Consider how to handle very large matrices that do not fit entirely in memory.
  2. Implement sqrt(x) using binary search.
  • Version A: return floor(sqrt(x)) for a non-negative 32-bit or 64-bit integer x without using built-in square root functions; avoid overflow and analyze complexity.
  • Version B: return a double approximation within 1e-6 for a non-negative real x; discuss stopping conditions, numerical stability, and edge cases (x=0, 0<x<1, very large x).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More TikTok•More Software Engineer•TikTok Software Engineer•TikTok Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.