Amazon OA

亚麻上网做题,遇见了水果顺序的题目,就是给你个array of array[[苹果,苹果],[橘子,香蕉,anything,苹果]],再给你个array[香蕉,苹果,苹果,香蕉,橘子,香蕉,香蕉,苹果]问世后面那array是不是前面那array of array 顺序的排了,在这个例子里面是算顺序排的,各个子array之间可以插入不同的值,但子array的顺序得对,子array内部的顺序也得对。

array of array:
[
1 --> [苹果,苹果],
2 --> [橘子,香蕉,anything,苹果]
]

array: [香蕉,苹果,苹果,香蕉,橘子,香蕉,香蕉,苹果]
--->    忽略 【match 1】忽略 【      match 2    】

第二个是给你个array of int,叫你给整成个bst, 然后再问你bst里面其中两个值之间的距离是多少。

另外看到别人的这题也报一下:

Given a list of unique integers nums , construct a BST from it (you need to insert nodes one-by-one with the given order to get the BST) and find the distance between two nodes node1 and node2 . Distance is the number of edges between two nodes. If any of the given nodes does not appear in the BST, return -1 .

Example 1:

Input: nums = [2, 1, 3], node1 = 1, node2 = 3
Output: 2
Explanation:

     2
   /   \
  1     3

报个AWS OA Deleting Arrays

You are given an array of A of N elements. You have performed Q queries in it. In each query, you can select an index I ( 0 - based) and perform the following operation:

for j = I + 1 to N
	if A[j] < A[i]
		A[j] = 0

You are required to print the version of array A after all queries Q .

Constraints :
1 <= T <= 10 (test cases)
1 <= N <= 10^5
1 <= A[i] <= 10^9
1 <= Q <= 10^5

Examples:
Input:
1 (no of test cases)
5 2 (N & Q)
4 3 4 3 2 (the queries)

Output:
4 3 4 0 0

Explanation:
After the first query: {4, 3, 4, 3, 0}
After the second query: {4, 3, 4, 0, 0}

还有 Mergers
You are given two strings A and B. You need to merge these strings, considering all characters that are both prefix of A and suffix of B once.

For example: A = “abcde”, B = “cdefg”, merged string = “abcdefg”.

Before merging, any one of the following operations can be performed at max once:

  • reverse A
  • reverse B
  • add 1 char at the end of A
  • add 1 char at the beginning of B

Print the minimum length possible for the merged string.

Constraints:
1 <= T <= 1000 (no of test cases)
1 <= |A|, |B| <= 10^4

Examples:
2 (no of test cases)
ababc
bcabc
cdefg
abhgf

Output:
8
8

Explanation:

  1. Perform no operation, merged string: ababcabc .
  2. Reverse B, merged string: cdefghba .

Amazon Online Assemement Questions.
Position: SDE1
Test Platform : HackerEarth
Test Pattern : 20 MCQ - Based On Computer Science Concepts (OS,DS,Algorithmis,Database) and 2 Coding Problems.
Test Duration : 90 Minutes

  1. Course Schedule : https://leetcode.com/problems/course-schedule/
  2. Reverse String || : https://leetcode.com/problems/reverse-string-ii/