PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Sunrise

Solve common data-structure and puzzle problems

Last updated: Mar 29, 2026

Quick Overview

Solve common data-structure and puzzle problems evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

  • easy
  • Sunrise
  • Coding & Algorithms
  • Software Engineer

Solve common data-structure and puzzle problems

Company: Sunrise

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Onsite

# Solve common data-structure and puzzle problems Solve the following independent problems (language of your choice; assume typical 32/64-bit constraints): 1) **Reverse a singly linked list** - Given the head of a singly linked list, reverse it and return the new head. (Iterative and/or recursive.) 2) **Numbering on an outward spiral grid** - Integers are written on an infinite 2D grid starting with `1` at `(0,0)`, then `2` at `(1,0)`, and continuing counterclockwise in an outward square spiral (right, up, left, down, ...). - Given integer coordinates `(x, y)`, compute the value written at that cell in **O(1)** time (no simulating the spiral). 3) **100 bulbs toggling** - There are 100 bulbs labeled `1..100`, all initially OFF. - Person 1 toggles every bulb; person 2 toggles bulbs `2,4,6,...`; person 3 toggles `3,6,9,...`; ...; person 100 toggles bulb `100`. - Which bulbs are ON at the end? 4) **Delete a node with only that node** - You are given a pointer/reference to a node `p` inside a singly linked list (you do **not** have the head pointer). - Delete `p` from the list in O(1) time. State any required assumptions. 5) **Bridge-and-torch scheduling** - Four people must cross a bridge with one torch. At most two people cross at a time, and they must carry the torch. - Their individual crossing times are `1, 2, 5, 6` minutes; when two cross together, the pair takes the slower person’s time. - Find a schedule that gets everyone across in **≤ 13 minutes**, or prove it’s impossible. 6) **Validate a BST** - Given the root of a binary tree, determine whether it satisfies the binary search tree property. 7) **Merge intervals** - Given a list of intervals `[start, end]` (inclusive), merge all overlapping intervals and return the merged list. 8) **Maximum adjacent gap after sorting** - Given an unsorted array of integers, if the array were sorted, what is the maximum difference between two adjacent elements in the sorted order? - Design an algorithm better than O(n log n) if possible, and state assumptions. ### Constraints & Assumptions - Preserve the scope, facts, inputs, and requested outputs from the prompt above. - If the prompt leaves a detail unspecified, state a reasonable assumption before relying on it. - Keep the answer interview-ready: concise enough to present, but concrete enough to implement or evaluate. ### Clarifying Questions to Ask - Clarify input sizes, value ranges, mutability, return format, and tie-breaking. - State the target time and space complexity before coding. - Call out edge cases such as empty inputs, duplicates, invalid values, overflow, and boundary sizes. ### What a Strong Answer Covers - A clear algorithm with the right data structures and enough pseudocode or code-level detail to implement it. - A correctness argument that explains why the algorithm covers all required cases. - Time and space complexity, plus at least one alternative approach when relevant. - Focused tests for normal cases, edge cases, and failure modes. ### Follow-up Questions - How would the approach change if the input were streaming or too large for memory? - What invariants would you assert in production code? - Which tests would catch off-by-one, duplicate, or tie-breaking bugs?

Quick Answer: Solve common data-structure and puzzle problems evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

|Home/Coding & Algorithms/Sunrise

Solve common data-structure and puzzle problems

Sunrise logo
Sunrise
Jul 21, 2025, 12:00 AM
easySoftware EngineerOnsiteCoding & Algorithms
2
0

Solve common data-structure and puzzle problems

Solve the following independent problems (language of your choice; assume typical 32/64-bit constraints):

  1. Reverse a singly linked list
  • Given the head of a singly linked list, reverse it and return the new head. (Iterative and/or recursive.)
  1. Numbering on an outward spiral grid
  • Integers are written on an infinite 2D grid starting with 1 at (0,0) , then 2 at (1,0) , and continuing counterclockwise in an outward square spiral (right, up, left, down, ...).
  • Given integer coordinates (x, y) , compute the value written at that cell in O(1) time (no simulating the spiral).
  1. 100 bulbs toggling
  • There are 100 bulbs labeled 1..100 , all initially OFF.
  • Person 1 toggles every bulb; person 2 toggles bulbs 2,4,6,... ; person 3 toggles 3,6,9,... ; ...; person 100 toggles bulb 100 .
  • Which bulbs are ON at the end?
  1. Delete a node with only that node
  • You are given a pointer/reference to a node p inside a singly linked list (you do not have the head pointer).
  • Delete p from the list in O(1) time. State any required assumptions.
  1. Bridge-and-torch scheduling
  • Four people must cross a bridge with one torch. At most two people cross at a time, and they must carry the torch.
  • Their individual crossing times are 1, 2, 5, 6 minutes; when two cross together, the pair takes the slower person’s time.
  • Find a schedule that gets everyone across in ≤ 13 minutes , or prove it’s impossible.
  1. Validate a BST
  • Given the root of a binary tree, determine whether it satisfies the binary search tree property.
  1. Merge intervals
  • Given a list of intervals [start, end] (inclusive), merge all overlapping intervals and return the merged list.
  1. Maximum adjacent gap after sorting
  • Given an unsorted array of integers, if the array were sorted, what is the maximum difference between two adjacent elements in the sorted order?
  • Design an algorithm better than O(n log n) if possible, and state assumptions.

Constraints & Assumptions

  • Preserve the scope, facts, inputs, and requested outputs from the prompt above.
  • If the prompt leaves a detail unspecified, state a reasonable assumption before relying on it.
  • Keep the answer interview-ready: concise enough to present, but concrete enough to implement or evaluate.

Clarifying Questions to Ask

  • Clarify input sizes, value ranges, mutability, return format, and tie-breaking.
  • State the target time and space complexity before coding.
  • Call out edge cases such as empty inputs, duplicates, invalid values, overflow, and boundary sizes.

What a Strong Answer Covers

  • A clear algorithm with the right data structures and enough pseudocode or code-level detail to implement it.
  • A correctness argument that explains why the algorithm covers all required cases.
  • Time and space complexity, plus at least one alternative approach when relevant.
  • Focused tests for normal cases, edge cases, and failure modes.

Follow-up Questions

  • How would the approach change if the input were streaming or too large for memory?
  • What invariants would you assert in production code?
  • Which tests would catch off-by-one, duplicate, or tie-breaking bugs?

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

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