[Amazon] ONLINE ASSESSMENT 2025 20 Dec

Problem 1: Binary String Palindrome Transformation

Description: You are given a binary string s consisting of characters '0' and '1'. Transform this string into a palindrome by performing swap operations. In one operation, swap any two characters, s[i] and s[j]. Determine the minimum number of swaps required to make the string a palindrome. If it is impossible to do so, return -1.

Note: A palindrome is a string that reads the same backward as forward. Examples of palindromes include "0", "111", "010", "10101". Non-palindromes include "001", "10", "11101".

Example:

  • Input string: s = "0100101"
  • Steps to transform:
    1. Swap characters at positions 4 and 5 (1-based index).
  • Result:
    • Transformed string becomes a palindrome.

Problem 2: Maximum Stability of Server Subsets

Description: AWS provides a range of servers for deployment. Each server has an availability and reliability factor. The stability of a set of servers is defined as:

Stability = (minimum availability in the set) * (sum of reliabilities in the set)

You need to find the maximum stability possible among all subsets of servers. Since the result can be large, return the answer modulo 1,000,000,007.

Input:

  • Two arrays:
    • reliability[]: An array representing reliability values of servers.
    • availability[]: An array representing availability values of servers.

Output:

  • Return the maximum stability value modulo 1,000,000,007.

Example:

  • Input:
    • reliability = [1, 2, 2]
    • availability = [1, 1, 3]
  • Subset calculations:
    • Subset {0}: Stability = 1 * 1 = 1
    • Subset {1}: Stability = 1 * 2 = 2
    • Subset {2}: Stability = 3 * 2 = 6
    • Subset {0, 1}: Stability = min(1, 1) * (1 + 2) = 3
    • Subset {0, 2}: Stability = min(1, 3) * (1 + 2) = 3
    • Subset {1, 2}: Stability = min(1, 3) * (2 + 2) = 4
    • Subset {0, 1, 2}: Stability = min(1, 3) * (1 + 2 + 2) = 5
  • Maximum stability is 6 (from subset {2}).

Constraints:

  • 1 <= number of servers <= 100,000
  • 1 <= reliability[i], availability[i] <= 1,000,000
  • Arrays reliability and availability have the same length.

我们长期稳定承接各大科技公司如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 *