Company: Tesco SDE offcampus_20july

Difficulty: medium

Problem Statement

Given two strings S and X (both S and X are composed of digits), write a program to find the sum of all the sub-strings of S that satisfy the following conditions: The sub-string must not begin with the digit '0' . And the numeric value that the sub-string represents must be greater than the value of X . Note: Two ways of selecting a sub-string are different if they begin or end at different indices. So identical-looking sub-strings taken from different positions are each counted separately. Illustrate the same by reading the input from STDIN and writing the output to STDOUT. You should not write arbitrary strings while reading the input and while printing as these contribute to the standard output. Constraints Input strings have only digits. Value of X is always less than that of S . 1 ≤ |S| ≤ 300 and 1 ≤ |X| ≤ 300, where |x| is the length of the string x. Note that the values involved can be far larger than a 64-bit integer, so arbitrary-precision arithmetic is required.

More Tesco SDE offcampus_20july OA questionsInterview experiences