[IBM] General SDE OA 60min

1. Question 1

Given an array of numbers, find the index of the smallest array element (the pivot), for which the sums of all elements to the left and to the right are equal. The array may not be reordered.

Example
arr = [1,2,3,4,6]

  • The sum of the first three elements, 1 + 2 + 3 = 6. The value of the last element is 6.
  • Using zero-based indexing, arr[3] = 4 is the pivot between the two subarrays.
  • The index of the pivot is 3.

Function Description
Complete the function balancedSum in the editor below.

balancedSum has the following parameter(s):
int arr[n]: an array of integers

Returns:
int: an integer representing the index of the pivot

Constraints


2. Question 2

Given a string array that contains n elements, each composed of lowercase English letters, and q queries, each query of the format l-r, for each query, determine how many strings starting from index l and ending at index r have vowels as the first and last character. Vowels are in {a, e, i, o, u}.

Example
strArr = ['aba', 'bcb', 'ece', 'aa', 'e']
queries = ['1-3', '2-5', '2-2']

These strings represent two dash delimited integers l and r, the start and end indices of the interval, inclusive. Using 1-based indexing in the string array, the interval 1-3 contains two strings that start and end with a vowel: 'aba' and 'ece'. The interval 2-5 also has three. The third interval, from 2-2, the only element in the interval, 'bcb' does not begin and end with a vowel. The return array for the queries is [2, 3, 0].

Function Description
Complete the hasVowels function in the editor below. It must return an array of integers that...


我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

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