Microsoft

SDE intern

OAFresherOtherBangaloreNov 2025

2 Questions

01

You are given an array stockPrice of length n where each element represents the closing stock price for a day. Choose a subsequence of days chosenDays. A subsequence is considered balanced if for every pair of consecutive chosen days: stockPrice[chosenDays[i]] - stockPrice[chosenDays[i-1]] = chosenDays[i] - chosenDays[i-1] for i > 0. The score of a subsequence is the sum of the stock prices on the chosen days. Your task is to find the maximum possible score from an optimally chosen balanced subsequence.

02

You are given n nodes numbered from 1 to n. Some nodes are already connected by existing edges. You are also given a list of possible new edges you can build, where each edge has an associated cost. Your task is to determine the minimum cost required to connect all nodes so that every node is reachable from every other node. If it is impossible to connect all nodes, return -1.

Addya mishra·Mar 2026

Share yours