Expected Cash Flow Analysis
A financial analytics platform is developing a feature to help investors understand the expected cash flows from their bond investments. Create a query that provides insights into each investor's expected cash flows.
The output should list all investors with their total number of investments, the sum of expected cash flows, and the range of expected cash flows (th
Asked in: ZSCALER
A Profitable Journey
A traveler moves through cities represented by an array of integers, where each integer indicates the money spent (negative) or earned (positive) in that city per day. The journey starts at city 0 and ends at city (n-1). The traveler can move to either an adjacent city or a city that is p steps away, where p is any prime number ending in 3.
Determine the maximum money th
Asked in: CISCO
Track Command Position
A network contains n nodes, where node 1 is the root node. The network structure is represented as a tree, with each node (except the root) having exactly one parent specified by the array par, where par[i] represents the parent of node i (1-based indexing).
Commands propagate through the network as follows: A node sends the command to its direct child nodes in ascendi
Asked in: ZSCALER
A class has students with various talents, each represented by an integer from 1 to talentsCount. You need to form teams for a quiz competition, where each team must have at least one member with each talent. Teams must be formed from consecutive students in the array. For each possible starting position, determine the minimum number of students needed to form a valid team. If it is not possible t
Asked in: ZS
1. Maximize the Revenue
There are n different types of items in a shop, where the number of items of type i is given by quantity[i]. The price of the items is determined dynamically, where the price of the ith item is equal to the remaining number of items of type i.
There are m customers in line, and each customer will buy exactly one item of any type. The shopkeeper aims to maximize revenu
Asked in: ZS
You are given an integer 'n', indicating that there are n family members labeled from 1 to n. This large family completes dinner in several rounds due to limited seating at the dining table (k seats) and prerequisite relationships between members, which may be children eating first, senior members eating first, or any other reason. You are also given an array of relations where relations[i] = [mem
Asked in: DPWORLD
There are two neighbours and they both have plates with their names written on them. Now, neighbour B wants to use neighbour A's plate because he lost his. So, B needs to make a nickname for himself. B has to remove the minimum number of consecutive characters from his name in such a way that it becomes a subsequence of A's plate. There is a possibility that he may have to remove all the character
Asked in: DPWORLD
Amazon Prime Day is a day where many items are put on sale for Amazon Prime members. A list of sale items is assembled where each item is assigned a category denoted by a lowercase English letter. Since the sale is to be held on two different days, the company has decided to partition the list of items into two contiguous non-empty sub-lists - a prefix and a suffix. To ensure that both the days sh
Asked in: AMAZON
Analyze the efficiency of the following sorting algorithm by counting the number of swaps it performs:
For an array `arr` of size `n`:
1. Find the smallest pair of indices 0 ≤ i < j ≤ n-1 such that arr[i] > arr[j], where "smallest" means lexicographical ordering of pairs (i1, j1) < (i2, j2) if i1 < i2 or (i1 = i2 and j1 < j2).
2. If no such pair exists, the algorithm stops.
3. Otherwise, swa
Asked in: UBER
Given a string composed of lowercase letters within the ASCII range 'a'-'z', determine the number of substrings that consist solely of vowels, where each vowel appears at least once. The vowels are ['a', 'e', 'i', 'o', 'u']. A substring is defined as a contiguous sequence of characters within the string.
Example
s = 'aeioaexaaeuiou'
There is a substring to the left that is made of vowel
Asked in: AMAZON