amazon OA1

7道debug题20分钟

1. Print Pattern 变量量ch++ -> print++

2. Even odd pattern 加括号

3. Manchester == -> !=

4. Reverse Array += -> -=

5. Sort Array > -> <

6. Get Digit sum parity result %2 == 0 -> !=

7. Distinct Element Count f==1 -> f==0

20分钟7道debug，题⽬目为：
1 sort array

2 奇数偶数

3 check palindromic num->temp

4 distinct element count

5 digitalSumPairy if (result % 2 !=0)->if (result % 2 ==0)

6 countproduct for loop ⾥里里⾯面限制条件错了了改下就好

7 找出出现k次的元素

OA2:

1. Work Simulation: ⽬前没有在⾯经里看到原题，佛系吧，还是那几个原则，

1. Logic：很多原题，正好做完

Logic前⾯面基本都是⼩⼟刀的原题，后面的应用题有一两个新题

1. ArrayOperation

3. printPattern

4. occurence

5. countDigit

6. EvenOddPattern

7. replaceValues

8/15 网上海投

OA1 debug 七题

OA2 70min 兩题 两个hashmap 统计⻛格 + 蠡⼝一三巴

Obstacle(背景：机器人去除障碍物) —>BFS搞定。

8⽉25号完成的OA, 过后recuiter 让我提供几个时间说要电话面试，昨天我把时间发给了recuiter, 过了⼀天 到现在recuiter还没有回信。。这种情况应该怎么办？

ps: 投的是加拿⼤大温哥华的职位。

countOccurrence

while loop⾥面缺少i++

printPattern（出现了两次）
for loop缺少 {}

selectionSort
<>改⼀一下

reverseArray

countDigits

lllll

Min Abs Diff Between 2 Elements

You are given an array `arr` of `n` elements of positive integers. Your task is to determine the minimum absolute difference between any 2 elements of the array. You can perform the following two types of operations on the array elements any number of times:

• If element `e` is even, then you can replace it by `e / 2`
• If element `e` is odd, then you can replace it by `2 * e`

Determine the minimum absolute difference between any two elements after performing this operation any number of times (possibly zero) on any element of the array.

Example 1:

``````Input: [1, 2]
Output: 0
``````

Constraints:

• 1<= `T` <=50
• 2<= `n` <=50000
• 1<= `arr[i]` <=10^8 for each valid `i`

Time limit: 1 sec

It is guaranteed that summation of `n` over all test cases does not exceed 250000.

2 Likes