Minimum Moves to Organize Weightlifting Blocks – Maximizing Area with Stick Rectangles – Amazon Coding Challenge Walkthrough-最少移动次数以排序重量块 – 亚马逊编程挑战解析-亚马逊OA- Amazon OA

Q1 Minimum Moves to Organize Weightlifting Blocks

Imagine you are shopping on Amazon.com for some good weight lifting equipment. The equipment you want has blocks of many different weights that you can combine to lift.

The listing on Amazon gives you an array, blocks, that consists of n different weighted blocks, in kilograms. There are no two blocks with the same weight. The element blocks[i] denotes the weight of the i^th block from the top of the stack. You consider weight lifting equipment to be good if the block at the top is the lightest, and the block at the bottom is the heaviest.

More formally, the equipment with array blocks will be called good weight lifting equipment if it satisfies the following conditions (assuming the index of the array starts from 1):

  • blocks[1] < blocks[i] for all (2 ≤ i ≤ n)
  • blocks[i] < blocks[n] for all (1 ≤ i ≤ n-1)

In one move, you can swap the order of adjacent blocks. Find out the minimum number of moves required to form good weight lifting equipment.

Q2 Maximizing Area with Stick Rectangles

Amazon games have introduced a new mathematical game for kids. You will be given n sticks and the player is required to form rectangles from those sticks.

Formally, given an array of n integers representing the lengths of the sticks, you are required to create rectangles using those sticks. Note that a particular stick can be used in at most one rectangle and in order to create a rectangle we must have exactly two pairs of sticks with the same lengths. For example, you can create a rectangle using sticks of lengths [2, 2, 5, 5] and [4, 4, 4, 4] but not with [3, 3, 5, 8]. The goal of the game is to maximize the total sum of areas of all the rectangles formed.


After the Amazon coding questions, there's a very simple workstyle type of multiple-choice question. With these kinds of questions, there's no need to guess the correct answers, just answer honestly according to what you feel is right, which typically only takes about 5 minutes. And just like that, a pleasant Online Assessment comes to an end. If anyone is aiming for a perfect score, feel free to contact me.

OA代做服务,代面试服务,面试辅助服务等,我们均有提供。欢迎联系我

If you're afraid that you can't solve the OA on your own, please scan the code to contact me or telegram

Leave a Reply

Your email address will not be published. Required fields are marked *