JPMorgan Chase OA High Frequency Questions Review|High Frequency Real Questions + Breakdown of Ideas in One Article

31 Views
No Comment

Recent JPMorgan Chase OA has begun to be distributed in batches, and the platform is still the familiar HackerRank. The overall difficulty is not high, but the rhythm requirements are very tight. It is a typical screening question that "you will get points if you know it, but you will get stuck if you don't know it". This time I share a very high-frequency combination: sliding window + greedy (heap). Basically, many people will encounter similar versions.

JPMorgan Chase

Topic 1: Highly Profitable Months

Question analysis

Question meaning: Given an array of stock prices StockPrices And parameters K, find all lengths K The continuous sub-intervals satisfy the strict increasing stock price within the interval, and count the number of such intervals.

  • Special circumstances: when K=1 When, all single elements meet the conditions, the length of the array is returned directly N.
  • Core judgment: For each length of K Window to check whether it satisfies StockPrices[i] < stockPrices[i+1] < ... < stockPrices[i+k-1].

Problem-solving ideas:

  1. First preprocess the array to generate an "increasing tag array":Inc[i] = 1 If and only if StockPrices[i] < stockPrices[i+1], otherwise 0.
  2. The length is K A strictly increasing interval of , which is equivalent to having a length of K-1 Continuous 1.
  3. Statistical markers consecutive in array K-1 Indivual 1 The number of windows is the answer.

Example:

StockPrices = [5, 3, 5, 7, 8],K=3

  • Tag array:[0, 1, 1, 1](because 5>3,3<5,5<7,7<8)
  • Find continuous 2 Indivual 1 Window:[1,1](Position 1-2),[1,1](Positions 2-3), total 2 , consistent with the example results.

Question 2: Array Reduction 1

Question analysis

Question meaning: Given an array of integers Num, each operation selects two different elements, deletes them and adds the sum to the end of the array, the operation cost is the sum of the two numbers. Find the minimum total cost of reducing an array to only 1 element.

Problem-solving ideas:

This is the classic Huffman Coding problem, which is equivalent to the merging fruit problem:

  • Each time the two smallest elements are merged, the total cost is the smallest.
  • Principle: Smaller numbers will be included in the total multiple times. Merging decimals first can allow their sum to be accumulated less times, thus minimizing the total cost.
  • Implementation: Use a minimum heap (small root heap), pop out the sum of the two minimum elements each time, put the sum back into the heap, and accumulate the cost until there is only one element left in the heap.

Example:

Num = [4,6,8]

  • Heap initialization:[4,6,8]
  • First merge:4+6=10,cost 10, the heap becomes [8,10]
  • Second merge:8+10=18,cost 18, the total cost 10+18=28, consistent with the sample minimum result.

A little sharing about JPMorgan Chase OA

This time I was able to pass JPMorgan Chase OA smoothly and quickly. To be honest, a large part of the reason was that I searched in advance. ProgramHelp Help with targeted preparations. Their team configuration is indeed quite hard-core: there are a total of 7 core people, all with top backgrounds, including backgrounds in prestigious schools, and there are also engineers working at first-tier manufacturers such as Amazon, Google and Alibaba.

In form, it is remote assistance, which will not affect your normal operation. It is overall relatively low-key and safe. If you are currently preparing for OA/written examinations such as JPMorgan Chase, Goldman Sachs, or Amazon, it will indeed be much more stable if you have someone to help you.

author avatar
Jory Wang Amazon Senior Software Development Engineer
Amazon senior engineer, focusing on the research and development of infrastructure core systems, with rich practical experience in system scalability, reliability and cost optimization. Currently focusing on FAANG SDE interview coaching, helping 30+ candidates successfully obtain L5/L6 Offers within one year.
END
 0