1p3a Question · Sep 2025

Google 2026 Summer Internship Online Test for SDE (General)

SWE OA Intern Easy
5 replies

Question Details

This post was last edited by George_333 on 2025-09-24 at 14:13. Two easy questions, newbie asking for points! A player is playing a game in which coins are placed on and removed from a table. The game

Full Details

This post was last edited by George_333 on 2025-09-24 at 14:13. Two easy questions, newbie asking for points! A player is playing a game in which coins are placed on and removed from a table. The game may consist of multiple rounds. At the beginning of each round the table is empty. There are three possible types of events: "i": increase, one additional coin is placed on the table. "d": decrease, a single coin is taken from the table. If the table is empty, nothing happens. "w": win, the player wins the round and takes all coins that are currently on the table. Write a function: def solution(events): that, given a string named events, representing the events that happened during the entire game,

returns the total number of coins won by the player. Examples: Given events = "idddiiw", the function should return 2.

Explanation: one coin is placed on the table; the coin is taken from the table; two "decrease" events have no effect (table is empty); two coins are placed on the table; player wins the two coins. Given events = "iiwdiwi", the function should return 3.

Explanation: player wins two coins in the first round; then one coin in the second round. events is a string consisting only of the characters "i", "d", and "w". Problem 2 There is an array A consisting of N integers. We call a sequence of three consecutive elements a triplet if their sum is equal to 0. What is the largest number of triplets that can be selected simultaneously? Each element of A can belong to only one triplet. Write a function: def solution(A): that, given an array A,

returns the largest number of triplets that can be selected simultaneously. Examples: A = [-4, 1, 0, -1, 0, 0, 0, 0] First triplet could be (0, 0, -1). Then, out of the five remaining zeros, only three can be selected (otherwise some would overlap). The function should return 2. A = [-1, 3, -1, 2, -1, 0, -3] Only one triplet (-1, -2, 3) can be selected. The function should return 1. A = [-1, -2, 3, -1, 0, 1] The function should return 2.

About This Question

This is a reported interview question from a google interview for a swe role (intern level) during the oa round reported in 2026.

It covers the following topics: Array, Arrays, Strings .

Difficulty rating: Easy