Question 1:
Problem description: A user is doing jump exercises using an Amazon fitness tracker. There are n blocks of different heights (height[i] is the height of the i-th block). The user starts from the ground (height 0) and must jump to every block exactly once, with the goal of maximizing calories burned. The calories burned jumping from block i to block j are calculated as (height[i] - height[j])^2. Once the user lands on a block, they cannot go back to the ground. Find the maximum calorie burn.
For example:
n = 3
height = [5, 2, 5]
Optimal jump order: ground -> block 3 -> block 2 -> block 1
Calories: (0-5)^2 + (5-2)^2 + (2-5)^2 = 25 + 9 + 9 = 43
Expected return value: 43
Question 2: Problem description: Determine whether two sets of passwords are similar. password1 and password2 are considered similar if, after removing all occurrences of at most one character from each (removing zero characters is also allowed), the two become anagrams of each other.
For example:
n = 1
password1 = "safddadfs"
password2 = "famafmss"
Remove all 'd' from password1 -> "safafs"
Remove all 'm' from password2 -> "faafss"
These two strings are anagrams, so return [true].
Discussion
Loading comments…