PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Google

Solve three coding interview problems

Last updated: Mar 29, 2026

Quick Overview

This set evaluates skills in string parsing and nested-structure decoding, optimization and stateful decision-making in one-dimensional arrays, and grid-based graph traversal for counting connected components.

  • medium
  • Google
  • Coding & Algorithms
  • Software Engineer

Solve three coding interview problems

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are given three independent coding questions. ## 1) Decode an encoded string Given an encoded string `s`, decode it using the following rule: - Patterns of the form `k[encoded_string]` mean that `encoded_string` is repeated exactly `k` times. - `k` is a positive integer and may have multiple digits. - Encoded strings may be nested. **Example**: `s = "3[a2[c]]"` should decode to `"accaccacc"`. **Task**: Return the decoded string. **Assumptions/constraints** (you may state any reasonable ones in your solution): - `s` contains only digits, letters, and brackets `[` `]`. - The input is valid (balanced brackets, well-formed encoding). --- ## 2) Max profit with jump decisions Given a 1D array `arr` of integers and starting at index `0`, you can make a decision at each index `i`: - **Take**: gain profit `arr[i]`, then jump to index `i + 1 + arr[i]`. - **Skip**: gain profit `0`, then move to index `i + 1`. You may stop when your index is out of bounds (i.e., `i >= n`). **Task**: Compute the maximum total profit achievable. ### Follow-up How does your approach change if `arr` can contain **negative numbers**? - If you **take** at index `i`, you still gain `arr[i]`, and you still move to index `i + 1 + arr[i]` (which could move backward if `arr[i] < 0`). - Clarify any assumptions needed to ensure termination and handle potential cycles. --- ## 3) Count connected land components in a grid Given an `m x n` grid of characters `'1'` and `'0'`: - `'1'` represents land - `'0'` represents water Two land cells are connected if they are adjacent **horizontally or vertically** (4-directional adjacency). **Task**: Return the number of connected components of land (i.e., the number of “islands”). **Example**: ``` 1 1 0 0 1 0 1 0 1 ``` Answer: `3`.

Quick Answer: This set evaluates skills in string parsing and nested-structure decoding, optimization and stateful decision-making in one-dimensional arrays, and grid-based graph traversal for counting connected components.

Related Interview Questions

  • Solve Flower Placement and Directory Deletion - Google (medium)
  • Compute Turnstile Crossing Times - Google (hard)
  • Simulate In-Place Cellular State Updates - Google (hard)
  • Determine Whether a Word Exists in a Graph - Google (medium)
  • Implement Checksums and Feature Rollout Evaluation - Google (medium)
Google logo
Google
Oct 9, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
6
0

You are given three independent coding questions.

1) Decode an encoded string

Given an encoded string s, decode it using the following rule:

  • Patterns of the form k[encoded_string] mean that encoded_string is repeated exactly k times.
  • k is a positive integer and may have multiple digits.
  • Encoded strings may be nested.

Example: s = "3[a2[c]]" should decode to "accaccacc".

Task: Return the decoded string.

Assumptions/constraints (you may state any reasonable ones in your solution):

  • s contains only digits, letters, and brackets [ ] .
  • The input is valid (balanced brackets, well-formed encoding).

2) Max profit with jump decisions

Given a 1D array arr of integers and starting at index 0, you can make a decision at each index i:

  • Take : gain profit arr[i] , then jump to index i + 1 + arr[i] .
  • Skip : gain profit 0 , then move to index i + 1 .

You may stop when your index is out of bounds (i.e., i >= n).

Task: Compute the maximum total profit achievable.

Follow-up

How does your approach change if arr can contain negative numbers?

  • If you take at index i , you still gain arr[i] , and you still move to index i + 1 + arr[i] (which could move backward if arr[i] < 0 ).
  • Clarify any assumptions needed to ensure termination and handle potential cycles.

3) Count connected land components in a grid

Given an m x n grid of characters '1' and '0':

  • '1' represents land
  • '0' represents water

Two land cells are connected if they are adjacent horizontally or vertically (4-directional adjacency).

Task: Return the number of connected components of land (i.e., the number of “islands”).

Example:

1 1 0
0 1 0
1 0 1

Answer: 3.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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