Nutanix 挂经

地点: San Jose, CA
Rounds: Online Assessment
Degree : MS in CS

90 minutes Online Assessment. Test would shut itself if searched anything on web or switched windows.

Problem 1:
Given a binary string, you can transform it by toggling 1s to 0s and vice versa. You can make as many transformations as you want. Find out the maximum string weight you can get with given string as explained below:
Given 3 numbers:

  • Weight of a single pair = p

  • Weight of a single character = s

  • Weight of a single transformation = t
    Note:

  • Weight of the transformed string = p + s - t.

  • A character in a string can be counted only once - either for a pair or a single character.

  • 2 adjacent characters are a pair only if they are different, i.e. 00 and 11 don’t form a pair but 01 and 10 do.
    Test cases:

Input: p, s, t, string = 4, 2, 1, "110"
Output: 6

Input: p, s, t, string = 4, 1, 1, "00"
Output: 3

Input: p, s, t, string = 4, 1, 1, "011"
Output: 5

Input: p, s, t, string = 4, 1, 1, "0000011"
Output: 11

Problem 2: Grumpy Bookstore Owner

Couldn’t solve problem 2 on time.