PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Meta

Solve three array/string/graph coding tasks

Last updated: Mar 29, 2026

Quick Overview

This set of three coding tasks evaluates proficiency in fundamental data structures and algorithms, covering multi-way array merging, custom character ordering and grouping, and graph cloning with correct handling of cycles and references.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Solve three array/string/graph coding tasks

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are given three separate coding tasks. Implement each as a function. ## 1) Merge three sorted arrays **Input:** Three integer arrays `A`, `B`, `C`, each sorted in non-decreasing order (may contain duplicates, may be empty). **Output:** A single array containing all elements from `A`, `B`, and `C` in non-decreasing order. **Constraints (typical):** Total length up to ~1e5. **Example:** - `A = [1, 4, 4]`, `B = [2, 6]`, `C = [0, 4, 10]` Output: `[0, 1, 2, 4, 4, 4, 6, 10]` --- ## 2) Sort characters by a given custom order You are given a string `order` that defines a custom ordering of (some) characters, and a string `s` to sort. **Rules:** - Characters that appear in `order` must appear in the output in the same relative order as in `order`. - If a character appears multiple times in `s`, all its occurrences should be grouped together. - Characters in `s` that do **not** appear in `order` should appear at the end (you may keep their relative order from `s`, or specify/implement a consistent rule). **Input:** `order` (string), `s` (string) **Output:** A reordered string. **Example:** - `order = "cba"`, `s = "abcdabc"` Output: `"ccbb aa dd"` without spaces → e.g. `"ccbbaad"` (all `c` first, then `b`, then `a`, then the remaining characters like `d`). --- ## 3) Deep copy (clone) a graph Given a reference to a node in a connected, undirected graph, return a **deep copy** (clone) of the entire graph. Assume each node has: - an integer `val` - a list of neighbor node references `neighbors` **Requirements:** - The cloned graph must contain entirely new nodes (no pointer/reference sharing with the original). - Adjacency (edges) must be preserved. - Handle cycles correctly. **Input:** A node reference `node` (or `null`). **Output:** A node reference to the cloned node corresponding to the input `node` (or `null`). **Edge cases to consider:** `null` input, single-node graph, cycles, self-loops.

Quick Answer: This set of three coding tasks evaluates proficiency in fundamental data structures and algorithms, covering multi-way array merging, custom character ordering and grouping, and graph cloning with correct handling of cycles and references.

Related Interview Questions

  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Array, Matrix, and Recommendation Problems - Meta (medium)
  • Find a String Containing Another - Meta (medium)
  • Solve Subarray Sum and Local Minimum - Meta (hard)
  • Validate abbreviations and brackets - Meta (medium)
Meta logo
Meta
Feb 11, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
3
0
Loading...

You are given three separate coding tasks. Implement each as a function.

1) Merge three sorted arrays

Input: Three integer arrays A, B, C, each sorted in non-decreasing order (may contain duplicates, may be empty).

Output: A single array containing all elements from A, B, and C in non-decreasing order.

Constraints (typical): Total length up to ~1e5.

Example:

  • A = [1, 4, 4] , B = [2, 6] , C = [0, 4, 10]
    Output: [0, 1, 2, 4, 4, 4, 6, 10]

2) Sort characters by a given custom order

You are given a string order that defines a custom ordering of (some) characters, and a string s to sort.

Rules:

  • Characters that appear in order must appear in the output in the same relative order as in order .
  • If a character appears multiple times in s , all its occurrences should be grouped together.
  • Characters in s that do not appear in order should appear at the end (you may keep their relative order from s , or specify/implement a consistent rule).

Input: order (string), s (string)

Output: A reordered string.

Example:

  • order = "cba" , s = "abcdabc"
    Output: "ccbb aa dd" without spaces → e.g. "ccbbaad" (all c first, then b , then a , then the remaining characters like d ).

3) Deep copy (clone) a graph

Given a reference to a node in a connected, undirected graph, return a deep copy (clone) of the entire graph.

Assume each node has:

  • an integer val
  • a list of neighbor node references neighbors

Requirements:

  • The cloned graph must contain entirely new nodes (no pointer/reference sharing with the original).
  • Adjacency (edges) must be preserved.
  • Handle cycles correctly.

Input: A node reference node (or null).

Output: A node reference to the cloned node corresponding to the input node (or null).

Edge cases to consider: null input, single-node graph, cycles, self-loops.

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.