Take FREE!! Online Mettl Mock Test to Crack TechM and Other Companies Written Exams.
Get Off-Campus Placement Jobs Info !!!
TCS NQT Technical and Managerial Round Interview Questions

Coding Questions Asked in Mettl

    1 / 6

    There are many cars parked in the parking lot. The parking is a straight very long line and a parking slot for every single meter. There are cars parked currently and you want to cover them from the rain by building a roof. The requirement is that at least k cars are covered by the roof. What's the minimum length of the roof that would cover k cars?

    The function has the following parameters:
    cars: integer array of length denoting the parking slots where cars are parked
    k: integer denoting the number of cars that have to be covered by the roof

    Example:
    Input:
    cars: [2, 10, 8, 17]
    k: 3
    output: 9
    Explanation: you can build a roof of length 9 covering all parking slots from the 2nd one to the 10th one, so covering 3 cars at slots 2, 10, 8, there are no shorter roof that can cover 3 cars, so the answer is 9

    Note:
    1 <= n <= 10^5
    1 <= k <= n
    1 <= cars[i] <= 10^14
    All slots token by cars are unique

    Input : cars: [2, 10, 8, 17]
    k: 3


    Output :

    View Answer |  Sorting |  Practice Program | Add to Reading List To Reading List | Asked In AmazonHackerRank |  Experience, Fresher
    Please Login to view the answer

    Tags:Amazon

    2 / 6

    Return the character which occurs for the maximum numbers of times in the Input String.
    If multiple characters occur with the same highest frequency then return "0".

    Input : Input1: abcdd


    Output :

    Please Login to view the answer

    3 / 6

    A prime number is a whole number greater than 1 that is divisible only by itself and the number 1.

    Given 'n' (1 <= n <= 100000), find the nth prime number.

    Input : An integer n


    Output :

    Please Login to view the answer

    4 / 6

    A Derangement is a permutation of n elements, such that no element appears in its original position. For example, a derangement of {0, 1, 2, 3} is {2, 3, 1, 0}.

    Given a number n, find the total number of Derangements of a set of n elements.

    Input : 1st Input: n = 2

    For two elements say {0, 1}, there is only one
    possible derangement {1, 0}

    2nd Input: n = 3

    For three elements say {0, 1, 2}, there are two
    possible derangements {2, 0, 1} and {1, 2, 0}


    Output :

    Please Login to view the answer

    5 / 6

    Every character in the input string is followed by its frequency.
    Write a function to decrypt the string and find the nth character of the decrypted string. If no character exists at that positionthen then return "-1".
    For eg:- If the input string is "a2b3" the decrypted string is "aabbb".
    Note: The frequency of encrypted string cannot be greater than a single digit i.e.<10.

    Explanation:

    The decrypted string is "abccc", hence the 5th character in the decrypted string is "c".

    Input : Input Specification:
    Input1: A string.
    Input2:5


    Output :

    Please Login to view the answer

    6 / 6

    Given a number of objects N(non-repetitive object) Find the number of arrangements in which no objects occur at original positions.

    Input : Input1: N, the number of Objects.
    Input1: 3


    Output :

    Please Login to view the answer




Q4I highly advised to practice all the basics and standard program asked at freshers or experienced level job interview in Mettl. Practice our hand-picked coding interview questions asked in Mettl. You can programed the given question in any language, you can post your answer and same time you can review the other answer. It is always recommanded to write your own program first and then refer others answers. At this page we have covers all the Mettl coding questions in 2020 and previously asked in their Interview round or coding rounds.