Open In App

APT Portfolio Interview Experience

Improve
Improve
Like Article
Like
Save
Share
Report

Online round: There are total 4 questions to solve and the round was held on HackerRank platform.

  1. Fun with Anagrams: Two strings are anagrams if they are permutations of each other. For example, “aaagmnrs” is an anagram of “anagrams”. Given an array of strings, remove each string that is an anagram of an earlier string, then return the remaining array in sorted order.Example: The given the strings s = [‘code’, ‘doce’, ‘ecod’, ‘framer’, ‘frame’], the strings ‘doce’ and ‘ecod’ are both anagrams of ‘code’ so they are removed from the list. The words ‘frame’ and ‘framer’ are not anagrams due to the extra ‘r’ in ‘framer’, so they remain. The final list of strings in
    alphabetical order is [‘code’, ‘frame’, ‘framer’].
  2. Maximizing Profit from Stocks: Your algorithms have become so good at predicting the market that you now know what the share price of Silly Purple Toothpicks Inc. (SPT) will
    be for a number of minutes going forward. Each minute, your high-frequency trading platform allows you to either buy one share of SPT, sell any number of shares of SPT that you own, or not make any transaction at all. Find the maximum profit you can obtain with an optimal trading strategy. Purchases are negative and sales are positive cash flows in the following equations.Example: If predicted prices over the next n = 6 minutes are prices = [3, 4, 5, 3, 5, 2], one way to the best outcome is to purchase a share in each of the first 2 minutes for cash flows -3 + -4 = -7, then sell them at the third minute for 2 * 5 = 10. Purchase a share in the 4th minute for 3 and sell it in the 5th minute for 5. Total profits are -3 – 4 + 10 – 3 + 5 = 5. Another way to the same outcome is to purchase a share in each of the 1st, 2nd and 4th minutes for -3 – 4 – 3 = -10, do nothing at minute 2 then sell all three shares at 5 (total 3 * 5 = 15) on the 5th day, again for a total profit of -10 + 15 = 5. There is no reason to purchase in the last minute as there is no time to sell.
  3. Parking Dilemma: There are many cars parked in the parking lot. The parking is a straight, very long line and has a parking slot for every single meter. There are n cars parked currently and you want to cover them from the rain by building a roof. The requirement is that at least k cars are covered by the roof. What’s the minimum length of the roof that would cover k cars?Example: There are 4 cars parked at slots 2, 10, 8 and 17 respectively and k = 3. Then, you can build a roof of length 9 covering all parking slots from the 2nd one to the 10th one, so covering 3 cars at slots 2, 10 and 8. There is no shorter roof that can cover 3 cars,
    so the answer is 9.
  4. Primes in Subtree: Construct a rooted undirected graph and then answer some queries on the graph. There are n nodes numbered from 1 to n. All the nodes are disconnected initially. Construct the graph by drawing an undirected edge between m pairs of nodes, picking one pair at a time and connecting the first and second nodes. After connecting each of the pairs, the graph construction is complete, and node 1 is the root node of this graph. A node’s parent is the next node on the shortest path from that node to node 1, and a descendant is on the shortest path to a leaf moving away from node 1. At this point, the graph can be considered a tree rooted at node 1, and subtrees can be formed rooted at any node and consisting of its descendants.Each node has a positive integer value associated with it. Find the total number of nodes with values as prime numbers in a given subtree rooted at a given node. Note that 1 is not a prime number. There are multiple queries.

Onsite round 1:

  1. Find Next Sparse Number:
    https://www.geeksforgeeks.org/given-a-number-find-next-sparse-number/

Onsite round 2:

  1. Find the smallest positive integer value that cannot be represented as sum of any subset of a given array: https://www.geeksforgeeks.org/find-smallest-value-represented-sum-subset-given-array/
  2. Design Elevator system:
    https://www.geeksforgeeks.org/problems/design-elevator

Last Updated : 26 Sep, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads