[Amazon] ONLINE ASSESSMENT 2024-12-26

Problem: Longest Self-Sufficient Proper Substring

A self-sufficient proper substring is defined as follows:

  1. The substring is not the entire string s.
  2. No letter that occurs inside the substring also occurs outside the substring.

Given a string fullString of length n, find the length of its longest self-sufficient proper substring. If none exists, return 0.


Function Description

Complete the function findLengthOfLongestSelfSufficientSubstring in the editor.

Parameters:

  • String fullString: The string to analyze.

Returns:

  • int: The length of the longest self-sufficient proper substring.

Example

Input:
fullString = "amazonservices"

Output:
11

Explanation:
The longest self-sufficient proper substring is "zonservices", which has a length of 11.


Constraints

  • fullString consists of lowercase letters.
  • 1 ≤ n ≤ 10^5

Problem: Maximize Solar Powered Bulbs

Description:
Solar power consumption has increased due to concerns over global warming. Some Amazon offices have decided to replace certain electricity-powered bulbs with solar-powered bulbs.

  • Electricity-powered bulbs are represented by '0', powered by a wired supply of electricity.
  • Solar-powered bulbs are represented by '1', powered by independent solar panels.

The goal is to maximize the number of solar-powered bulbs while adhering to the following rules:

  1. An electricity-powered bulb (represented by '0') can only be replaced by a solar-powered bulb (represented by '1') if doing so does not result in two adjacent solar-powered bulbs.
  2. The initial configuration may already contain adjacent solar-powered bulbs, but the replacement must adhere to the rule.

Find the total maximum number of solar-powered bulbs that can be placed in the office, not just the number of bulbs replaced.


Function Description

Complete the function maximizeSolarPoweredBulbs in the editor.

Parameters:

  • String bulbs: A string representing the arrangement of bulbs.

Returns:

  • int: The maximum number of solar-powered bulbs that can be placed.

Example

Input:

bulbs = "1111110001"

Output:

8

Explanation:

  1. Initially, there are 7 solar-powered bulbs (1).
  2. Only the 8th bulb (index 8) can be replaced with a solar-powered bulb, as replacing any of the other positions would result in two adjacent solar-powered bulbs.
  3. With this replacement, the total number of solar-powered bulbs becomes 8.

Constraints

  • The length of the string bulbs can be up to 10^5.

Additional Note

  • If the provided "Return -3" statement is a mistake, it should be ignored as the output in the example calculation is clearly 8.

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