PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Meta

Implement merge-in-place and group cyclic-equivalent strings

Last updated: Mar 29, 2026

Quick Overview

This question evaluates array-manipulation and string-normalization competencies, specifically in-place merging of sorted arrays without extra space and grouping strings by cyclic-shift equivalence.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Implement merge-in-place and group cyclic-equivalent strings

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

You are given two ascending arrays to merge in place and a separate grouping task: Part A — In-place merge without known sizes: - Array A contains sorted integers followed by empty slots, but the counts m (valid values) and k (empty slots) are not provided. Empty slots are represented by a sentinel (e.g., None). Array B contains n sorted integers. You must merge all values from B into A so that A becomes fully sorted, using O( 1) extra space. - Tasks: 1) Describe and implement an O(m+n)-time algorithm that determines m and then performs the merge in place. State assumptions, edge cases (duplicates, negatives, one array empty), and time/space complexity. 2) Follow-up: Can you merge by scanning from the beginning of both arrays instead of from the end? Explain why or why not for an in-place algorithm without extra buffers, and give a concrete example illustrating overwrite/instability or the conditions under which forward merging would work. Part B — Group strings by uniform cyclic shift: - Given an array of lowercase strings, group strings that are equivalent under a uniform cyclic letter shift (wrapping modulo 26) and have the same length. For example, "abc" and "bcd" belong together; "az" and "ba" belong together. - Tasks: 1) Define a canonical key/normalization for grouping and implement an algorithm to return all groups. 2) Analyze time and space complexity. Discuss handling of mixed lengths, empty strings, and non-letter characters if present.

Quick Answer: This question evaluates array-manipulation and string-normalization competencies, specifically in-place merging of sorted arrays without extra space and grouping strings by cyclic-shift equivalence.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Maze and Suffix Problems - Meta (medium)
Meta logo
Meta
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

You are given two ascending arrays to merge in place and a separate grouping task:

Part A — In-place merge without known sizes:

  • Array A contains sorted integers followed by empty slots, but the counts m (valid values) and k (empty slots) are not provided. Empty slots are represented by a sentinel (e.g., None). Array B contains n sorted integers. You must merge all values from B into A so that A becomes fully sorted, using O(
  1. extra space.
  • Tasks:
    1. Describe and implement an O(m+n)-time algorithm that determines m and then performs the merge in place. State assumptions, edge cases (duplicates, negatives, one array empty), and time/space complexity.
    2. Follow-up: Can you merge by scanning from the beginning of both arrays instead of from the end? Explain why or why not for an in-place algorithm without extra buffers, and give a concrete example illustrating overwrite/instability or the conditions under which forward merging would work.

Part B — Group strings by uniform cyclic shift:

  • Given an array of lowercase strings, group strings that are equivalent under a uniform cyclic letter shift (wrapping modulo
  1. and have the same length. For example, "abc" and "bcd" belong together; "az" and "ba" belong together.
  • Tasks:
    1. Define a canonical key/normalization for grouping and implement an algorithm to return all groups.
    2. Analyze time and space complexity. Discuss handling of mixed lengths, empty strings, and non-letter characters if present.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta 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.