Uber | OA | University 2021 | code signal

Q-1
Edward and Alphonse are alchemists. They want to perform human transmutation to revive their mother and need philosopher stones for it. Father Inc has a factory which produces philosopher stones. The factory will run for n days. On day i the factory will produce A[i] stones. These stones also have a expiry date! The stones produced on day i can only be used for D[i] days. So if D[i] = 1 those stones can only be used on the day they are produced and so on
Edward and Alphonse want to maximise their chances to succeed at the transmutation. For this tell them the maximum number of stones they can use for the transmutation.

  • [execution time limit] 1 seconds (cpp)
  • [input] array.integer stones
    This is an array of the number of stones produces on day 1, 0 <= stones[i] <= 10000000.
    No of array elements <= 100000
  • [input] array.integer days
    This is an array of the number of days stones produces on day i can be used for 0<days[i]<1000000.
    No of array elements <= 100000
  • (output) integer
    Output an integer which is the maximum number of stones that can be used for the transmutalen As the answer can be large give the result modulo 1000000007.

Q-2
You are given two strings S and T. An infinitely long string is formed in the following manner. Take an empty string Append S one time Append T two times. Append S three times. Append T four times. and so on, appending the strings alternately and increasing the number of repetitions by 1 each time You will also be given an integer K, you need to tell the Kth Character of this infinitely long string.

  • Sample Input:
    S="a". T="bc", k = 4
  • Sample Output:
    b
  • Sample Explanation:
    The string formed will be "abcbcaaabcbcbcbcaaaaa." So the kth character is "b".
  • [execution time limit] 1 seconds (cpp)
  • [input] string s
    The first string. 1 < len(S) <= 100
  • [input] string t
    The second string. 1 < len(T) <= 100.
  • [input] integer64 k
    The integer K, as above 1 <= K <= 10^16
  • [output] char
    The kth character of the infinitely long concatanated string.

Q-3
You are given 4 integers A,B,C and D. You need to find the following sum:

	sum = 0
	for(i=A;i<=B;i++)  
		for(j=C;j<=D;j++)  
			sum = sum + (i^j)
		

Here ^ nds for the bitwise XOR operation Since the final sum can be huge, you should return the output modulo 1000000007 (10^9 + 7)

  • Sample Input:
    A=1, B = 2, C = 3, D = 4

  • Sample Output:
    14

  • Explanation:
    The required sum would be (1^3)+(1^4) + (2^3) +(2^4) =2+5+1+6=14

  • [execution time limit] 1 seconds (cpp)

  • [input] integer a
    1 <= A <= 10^9

  • [input] integer b
    A <= B <= 10^9

  • [input] integer c
    1 <= C <= 10^9

  • [input] integer d
    C <= D <= 10^9

  • [output) integer
    The required sum. module 1000000007.

Comments (2)