Loading Now

greatestInteger

Given 2 very big integers n and k which are represented as 2 strings

Find the greatest integer which less than or equal to n and divided by 2 only k times. If there’s no solution, return -1.

Example

  • For n = "13", k = "2", the output should be greatestInteger(n, k) = "12"

Input/output:

  • [execution time limit] 0.5 seconds

  • Input: integer n, k
    Guaranteed constraints:
    1 <= n <= 10^1000, 1 <= k <= 2300
  • Output: integer 
    The greatest integer

Post Comment

Contact