PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of clustering algorithms and optimization of within-cluster squared error for the special case k = 1, along with the ability to implement a numerical solution in d-dimensional space.

  • easy
  • Sealth
  • Coding & Algorithms
  • Machine Learning Engineer

Implement one-cluster k-means

Company: Sealth

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Onsite

Given n points in d-dimensional space, implement k-means clustering with squared Euclidean distance for the special case k = 1. Return the single centroid that minimizes the total within-cluster squared error over all points. The interviewer may also ask you to explain why this special case converges immediately without repeated reassignment steps.

Quick Answer: This question evaluates understanding of clustering algorithms and optimization of within-cluster squared error for the special case k = 1, along with the ability to implement a numerical solution in d-dimensional space.

For k=1, return the coordinate-wise mean centroid rounded to 6 decimals.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([(0,0),(2,2),(4,4)],)

Expected Output: [2.0, 2.0]

Explanation: Centroid is the coordinate-wise mean.

Input: ([(1,2,3)],)

Expected Output: [1.0, 2.0, 3.0]

Explanation: Single point centroid is itself.

Hints

  1. Clarify edge cases before coding.
  2. Keep the return value deterministic.
Last updated: Jun 27, 2026

Related Coding Questions

  • Simulate Threshold Grid Infection - Sealth (medium)
  • Decode Ambiguous Morse Messages - Sealth (medium)

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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
  • AI Coding 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.