# 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 (23)*

*SAP Labs (18)*

*TCS NQT (23)*

*TCS Ninja (4)*

*Huawei (1)*

381 / 411

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

**Tags:**Amazon

382 / 411

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

383 / 411

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

**Input : ** NA

**Output : ** NA

384 / 411

Eg :- l = 1

r = 10

**Input : ** NA

**Output : ** NA

**Tags:**SAP Labs TCS NQT Wipro NLTH

385 / 411

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

**Tags:**TCS NQT Wipro NLTH

386 / 411

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

**Tags:**TCS NQT Wipro NLTH

387 / 411

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

**Tags:**TCS NQT Wipro NLTH

388 / 411

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

**Input : ** NA

**Output : ** NA

**Tags:**TCS NQT Wipro NLTH

389 / 411

If multiple characters occur with the same highest frequency then return "0".

**Input : ** Input1: abcdd

**Output : **

**Tags:**TCS NQT Nagarro Wipro NLTH

390 / 411

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

**Input : ** An integer n

**Output : **

**Tags:**TCS NQT Nagarro Wipro NLTH

#### Top Kudos Contributor

####
* Trending Programming Qs.*

- Given two vectors. One contains array element "ele" and other indexes ...
- Given a string, say sentence=" this is crazy and fun" and a list, say ...
- Write a program to print next to the last word of a sentence.
- Write a program to convert uppercase to lower case and vice versa of a...
- There are many cars parked in the parking lot. The parking is a straig...
- There are many cars parked in the parking lot. The parking is a straig...

####
* Last Month Contributor*

####
* Most Popular Programming Qs.*

- 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.
- There are many cars parked in the parking lot. The parking is a straig...
- Given a string, say sentence=" this is crazy and fun" and a list, say ...
- Write a program to remove the vowels from the input string.