Cisco Cisco OA-6 2022 Problem Description A grocery store needs to select a set of apples where the weight difference between the largest and smallest apple is no more than k. Given the range k, find the maximum number of apples that can be selected from the input set of N apples. Input Format:
Oracle Oracle OA-7 2023 Problem Description A renowned mathematician, Anna Taylor, was known for her significant contributions to number theory, particularly in the study of prime numbers and divisibility. One of the essential tools in number theory is the Greatest Common Divisor (GCD), which has numerous applications, including in algorithms related to cryptography. For
Cisco Cisco OA-7 2022 Problem Description Given an encoded string s, return its decoded string. The encoding rule is k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assume that the input string is
Google Google OA-8 2024 Problem Description You have an infinitely long array initialized with zeros. You are given two integers, N and K, and for the next N lines, you will receive three integers L, R, and X. This indicates that you need to add X to every element in the array from index
Flipkart Flipkart OA-7 2023 Problem Description A taxi company is enhancing its app to help drivers find the shortest route between two cities on any given trip. There are N cities, each represented by a unique integer from 1 to N. Every city is directly connected to any other city through two possible routes:
Morgan Stanley Morgan Stanley OA-7 2022 Problem Description You are given an array that contains integers in ascending order followed by integers in descending order. All integers in the array are unique and appear only once. Your task is to compute the product of the sum of the values in the ascending part and the sum
Uber Uber OA-5 2023 Problem Description It is the year 2050, and humans have evolved into two supernatural species: Alpha (Alph) and Beta (Bts). Yakohama, the kingdom of the Alpha group, is under threat from Beta members who plan to attack through a secret path in the forest. Akari, the king of Yakohama, must
Juspay Juspay OA-7 2023 Problem Description You are given a maze with N cells, where each cell may have multiple entry points but no more than one exit. The cells are numbered from 0 to N-1. The task is to find the node with the maximum weight. The weight of a node is defined
Salesforce SalesForce OA-7 2023 Problem Description Alex is on an adventure and needs to cross a stone bridge where each stone is labeled with a random string of characters (S). He can only jump onto stones that are labeled with special characters, which are defined as any characters that are not letters (i.e.
Cisco Cisco OA-8 2022 Problem Description Given an integer array nums, find the subarray with the largest sum, and return its sum. Constraints: * 1 < nums.length <= 10^5 * -10^4 < nums[i] <= 10^4 Test Case Example 1 Input: nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4] Output:
Google Google OA-9 2024 Problem Description You are given the following: * A tree with N nodes. * An array A that represents the value of each node. * A non-negative integer K. You are allowed to perform the following operation at most once: 1. Select a node r and make it the new root of the
Morgan Stanley Morgan Stanley OA-8 2022 Problem Description You are given an array of size n. You need to remove elements from the array in such a way that exactly three adjacent elements are removed in one turn. The elements that can be removed must satisfy the following conditions: * The second element is k greater than
Uber Uber OA-6 2023 Problem Description Samuel has gifted Tina the Magical Dice Game for her birthday. This game involves a strip of T cells, where some cells are empty (denoted by 0), and some are blocked (denoted by 1). Tina and Samuel decide to play a competitive game on this strip. The game
Juspay Juspay OA-8 2023 Problem Description You are given a world map represented as an M-ary tree. Each node in the tree represents a location with a unique name. There are three types of operations to be performed on this tree: 1. lock(X, uid): Locks the subtree rooted at node X by user
Salesforce SalesForce OA-8 2023 Problem Description You are given an encoded string that needs to be decoded using the following steps: 1. Reverse the encoded string. 2. Convert the numerical representation to ASCII characters: * The encoded string consists of numbers that represent ASCII values of characters. * Each ASCII value is either for: * Uppercase letters
Oracle Oracle OA-8 2024 Problem Description As new students begin to arrive at college, each receives a unique ID number from 1 to (n). Initially, the students do not know one another, and each has a different circle of friends. As the semester progresses, other groups of friends begin to form randomly. There will
Cisco Cisco OA-9 2023 Problem Description In theoretical mathematics, a 'Happy Number' is defined as a number that, when repeatedly replaced by the sum of the squares of its digits, eventually reaches 1. Numbers that do not reach 1 will get trapped in a cycle that excludes 1. Your task is to
Google Google OA-10 2024 Problem Description You are given an array A of N integer elements. You are also given Q queries, where each query is one of the following types: 1. 1 i val. Update the value of the element at the i-th index to val i.e. A[i]=val. 2. 2
Morgan Stanley Morgan Stanley OA-10 2024 Problem Description An organization is hosting an event with multiple stalls, each connected by one-directional roads. There are N stalls and the goal is to visit every road in such a way that all the stalls are visited without causing any congestion. Every road connects two stalls directly or indirectly
Uber Uber OA-7 2023 Problem Description There are n doors, and behind each door is either a rabbit or a tortoise. You know the following: * There are x rabbits and y tortoises behind the doors. * The total number of doors is n = x+y. * No two rabbits are adjacent, meaning no two consecutive doors
Juspay Juspay OA-9 2023 Problem Description JS newbie A wants to learn React from B and wants to figure out who in his network can introduce him to B in the shortest time period. The social network is modeled as a directed graph where: * N is the total number of members in the network.
Salesforce SalesForce OA-9 2023 Problem Description You are given three points: a(x1, y1), b(x2, y2), and c(x3, y3). The task is to check whether these points form a non-degenerate triangle. Additionally, you are provided two other points, p(x_p, y_p) and q(x_q, y_q). If the points
Oracle Oracle OA-9 2024 Problem Description Given an integer, store its binary representation as a string or an array with digits indexed from 0 to length(bin) - 1. Reduce its binary representation to zero by using the following operations: 1. Change the t-th binary digit only if the (i + 1)-th binary digit
Cisco Cisco OA-10 2023 Problem Description The blueprint of a room is represented by a 2D array of 1's and 0's, where: * 1 represents walls. * 0 represents empty spaces. Task: Group the empty spaces into rooms with labels matching their size. For example, if a bounded space is 3 units
Google Google OA-11 2024 Problem Description You are given N integers that represent the locations of homes along a straight street (on the x-axis). The i-th home is located at A[i]. Your goal is to find the optimal integer location X for building a dark store such that the sum of the squared