Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

Programming Questions in JAVA Asked at Freshers

    201 / 212

    Given an array of integers with repeating elements, find the sum of differences between positions of repeated elements and store them in an array of the same size.

    For e.g. given array {1, 2, 3, 1, 2, 1, 2} we shall have:
    For position 0: 1 is on positions 3&5 additional to position 0.
    Thus for position 0: |3-0| + |5-0| = 8.
    For position 1: 2 is on positions 4&6 additional to position 1.
    Thus for position 1: |4-1| + |6-1| = 8.

    Input : NA


    Output : NA

    View Answer |  Array |  Practice Program | Add to Reading List To Reading List | Asked In SAP LabsTCS NQT |  Experience, Fresher
    Please Login to view the answer

    202 / 212

    Finding palindromic substrings within a string

    For e.g. given string ‘banana’, palindromic substrings would be ‘aa’, ‘aaa’, ‘ana’, ‘anna’ and so on.

    Input : NA


    Output : NA

    View Answer |  Array |  Practice Program | Add to Reading List To Reading List | Asked In SAP LabsTCS NQT |  Experience, Fresher
    Please Login to view the answer

    203 / 212

    Find the count of prime numbers between l and r where 1 <= l, r <= 10 ^ 9 and those numbers whose digits are not even numbers and digits are less than 5

    Eg :- l = 1
    r = 10

    Input : NA


    Output : NA

    View Answer |  Basics |  Practice Program | Add to Reading List To Reading List | Asked In SAP LabsTCS NQT |  Experience, Fresher
    Please Login to view the answer

    204 / 212

    Given a matrix with 0’s and 1’s, you enter the matrix at cell (0,0) in left to the right direction. whenever you encounter a 0 you retain in the same direction, if you encounter a 1’s you have to change direction to the right of current direction and change that 1 value to 0, you have to find out from which index you will leave the matrix at the end.

    Input : The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains two lines . The first line of each test case contains two integers n and mdenoting the size of the matrix. Then in the next line are n*mspace separated values of the matrix.


    Output :

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

    Tags:TCS NQT

    205 / 212

    Given a value V, if we want to make a change for V cents, and we have an infinite supply of each of C = { C1, C2, .., Cm} valued coins, what is the minimum number of coins to make the change?

    Input : The first line of input contains an integer T denoting the number of test cases.
    The first line of each test case is V and N,V is the value of cents and N is the number of coins.
    The second line of each test case contains N input C[i],value of available coins.


    Output :

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

    Tags:TCS NQT

    206 / 212

    In the below given series:


    1, 2, 1, 3, 2, 5, 3, 7, 5, 11, 8, 13, 13, 17, ...


    This series is a mixture of 2 series - all the odd terms in this series form a Fibonacci series and all the even terms are the prime numbers in ascending order.


    Write a program to find the Nth term in this series.
    Note:
    The value N is a Positive integer that should be read from STDIN. The Nth term that is calculated by the program should be written to STDOUT. Other than the value of Nth term, no other characters/strings or message should be written to STDOUT.


    For example, when N = 14, the 14th term in the series is 17. So only the value 17 should be printed to STDOUT.

    Input : 14


    Output :

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

    Tags:TCS NQT

    207 / 212

    Given a series whose even term creates a separate geometric series and odd term creates another geometric series.


    Write a program to generate such series.For example,1, 1, 2, 2, 4, 4, 8, 8, 16, 16,......

    Input : NA


    Output : NA

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

    Tags:TCS NQT

    208 / 212

    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 :

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

    209 / 212

    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

    210 / 212

    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




You at page 21 practice here all the basics and standard c, C++, JAVA, Python program asked at freshers level job interview or in coding round. Practice our hand-picked 21 coding round programming interview questions asked in coding round of various it companies and exams. You can practice all the given at this page 21 programed given C, C++, JAVA, Python question in any language, you can post your answer and same time you can review other users answer. It is always recommanded to write your own C, C++, JAVA, Python coding questions answer first and then refer others answers. At this page 21 we have covers all the coding questions in 2020-2021 and previously asked in their Interview round or coding rounds.