Preparing for an interview? Check out Cracking the Coding Interview
Published on

JP Morgan Chase and Co. | Online Assessment | Round 1 | CLEARED | April 2024

Author
  • Shared Anonymously

Recently, I had the exciting opportunity to participate in the JPMorgan Chase & Co. (Round I), and I'd love to share my experience with you all!

Basically it was screening round for the position of summer intern. (2nd year)


First Question: Substring Removal

Problem Statement:
Given a string, 'seq' that consists of the characters 'A' and 'B' only, in one move, delete either 'AB' or a 'BB' substring and concatenate the remaining substrings
Note: A substring is a contiguous subsequences of a string.
Return the minimum possible length of remaining string after performing any number of moves

Eg. seq = "BABBA", o/p = 1

Topic tags : Stack, String
Expected time complexity : O(n)
Expected space complexity : O(n)
Testcases Passed : ALL


Second Question: Jack and Jones

Problem Statement:
Jack and Jones are two hackers playing a fun game. They are a 'query' array of non-empty strings.
Each string in this array signifies a single round of the game, return the array of strings denoting winner of each round.

Game Rules :

  1. Jack always plays the first turn.
  2. Jack selects a substring which has odd number of vowels in it from the string, and also removes the same from the original string.
  3. Jones selects a substring which has even number of vowels (!= 0) in it from the string, and also removes the same from the original string.
  4. This way the round continues...
  5. The player loses a round if he is left with nothing to pick from the string.

Eg: query = ["Leetcode", "DSA", "Sphynx"], o/p = ["Jack", "Jack", "Jones"]

Note: Consider both players play each round optimally.

Topic tags : Mathematics, Simulation
Expected time complexity : O(1)
Expected space complexity : O(1)
Testcases Passed : ALL


Note:

  1. Don't be intimidated by time/space complexities. Start by simulating the problem, then progressively optimize your algorithm. Soon, you'll get closer to achieving constant efficiencies.

  2. Time and Space complexities and Topic tags were not provide by JPMorgan Chase and Co., by having a conversation with my college-mates, I concluded that these were probably what they were expecting.

ReportMark as Helpful