# Programming Questions and Answers

*TCS (25)*

*Capgemini (5)*

*Hewlett Packard Enterprise (5)*

*Ciena (16)*

*Adobe (5)*

*Alcatel-Lucent (6)*

*Ericsson (1)*

*Broadcom Ltd (18)*

*Radisys (6)*

*Aricent (8)*

*IpInfusion (1)*

*Cisco (28)*

*Brocade (20)*

*Wipro (25)*

*Cavium Networks (8)*

*XiLinx (3)*

*Juniper Network (10)*

*HCL Technologies (11)*

*Amazon (5)*

*IBM (23)*

*Global Edge (17)*

*Accenture (15)*

*Qualcomm (4)*

*CA Technologies (6)*

*Nagarro (8)*

*Tech Mahindra (1)*

*Syntel Inc. (10)*

*Tavant Technologies (15)*

*Amdocs (1)*

*Virtusa (36)*

*PEOL (15)*

*Sapient (3)*

*Societe Generale (4)*

*Wipro NLTH (22)*

*SAP Labs (18)*

*TCS NQT (12)*

*TCS Ninja (4)*

*Huawei (1)*

391 / 404

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 : **

**Tags:**TCS NQT Nagarro Wipro NLTH

392 / 404

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 : **

**Tags:**Nagarro Wipro NLTH TCS Ninja

393 / 404

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

Input1: 3

**Output : **

**Tags:**Nagarro Wipro NLTH Wipro NLTH

394 / 404

This series is a mixture of 2 series - all the odd terms in this series form a geometric series and all the even terms form yet another geometric series. Write a program to find the Nth term in the series.

The value N in 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 value of n th term,no other character / string or message should be written to STDOUT. For example , if N=16, the 16th term in the series is 2187, so only value 2187 should be printed to STDOUT.

You can assume that N will not exceed 30.

**Input : ** if N=16

**Output : **

**Tags:**TCS NQT Wipro NLTH

395 / 404

This series is a mixture of 2 series all the odd terms in this series form even numbers in ascending order and every even terms is derived from the previous term using the formula (x/2)

Write a program to find the nth term in this series.

The value n in 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 the nth term no other characters /strings or message should be written to STDOUT.

For example if n=10,the 10 th term in the series is to be derived from the 9th term in the series. The 9th term is 8 so the 10th term is (8/2)=4. Only the value 4 should be printed to STDOUT.

You can assume that the n will not exceed 20,000.

**Input : ** NA

**Output : ** NA

**Tags:**TCS NQT Wipro NLTH

396 / 404

**Input : ** {-2, -3, 3, -1, -2, 1, 5, -3}

**Output : **

**Tags:**Huawei Wipro NLTH TCS Ninja

397 / 404

For example, the program should print 'balanced' for exp = “[()]{}{[()()]()}” and 'not balanced' for exp = “[(])”

**Input : ** The first line of input contains an integer T denoting the number of test cases. Each test case consists of a string of expression, in a separate line.

**Output : **

**Tags:**Wipro NLTH TCS Ninja

398 / 404

**Input : ** The first line of input contains an integer T, denoting the number of testcases. Then T test cases follow. Each test case contains an integer N, denoting the size of the square matrix. Then in the next line are N*N space separated values of the matrix.

**Output : **

**Tags:**Wipro NLTH

399 / 404

Right rotate the array clockwise by 1.

Delete the (n-k+1)th last element.

Now, find the element which is left at last.

**Input : ** The first line of input contains an integer T denoting the number of test cases. Then T test cases follows. Each test case contains two lines. The first line of each test case contains an integer N. Then in the next line are N space separated values of the array arr[].

2

4

1 2 3 4

6

1 2 3 4 5 6

**Output : **

**Tags:**Wipro NLTH

400 / 404

**Input : ** Input: N = 3, arr[] = {2, 4, 6}

Explanation: GCD of 2,4,6 is 2.

**Output : **

**Tags:**Wipro NLTH

#### Top Kudos Contributor

####
* Trending Programming Qs.*

- Write a program to convert uppercase to lower case and vice versa of a...
- Return the character which occurs for the maximum numbers of times in ...
- Write a program to print next to the last word of a sentence.
- Given an array of size MxN and coordinates of starting of subarray (x,...
- Write a program to print next to the last word of a sentence.
- Write a program to print next to the last word of a sentence.

####
* Last Month Contributor*

- Write a program to convert uppercase to lower case and vice versa of a...
- Write a program to print next to the last word of a sentence.
- Return the character which occurs for the maximum numbers of times in ...
- Write a program to remove the vowels from the input string.
- Given an array of size MxN and coordinates of starting of subarray (x,...

## Login

Or

Register Here...## Register

## Register As