Intel Coding Questions and Answers

Intel Coding Questions with Solution

Here, on this page you will find all sample Intel Coding Questions with Solution, which will help you to prepare for Online Assessments and Technical Interviews of Intel for hiring freshers.

intel-coding-questions

Intel Sample Coding Questions and Answers

Question 1 : Weird Terminal

Problem Statement : 

Here is a weird problem in Susan’s terminal. He can not write more than two words each line, if she writes more than two, it takes only 2 words and the rest are not taken. So she needs to use enter and put the rest in a new line. For a given paragraph, how many lines are needed to be written in Susan’s terminal?

Input Format:

A string as the text to input in the terminal

Output Format:

Number of lines written.

Constraints:

Number of words <=10^7

Sample Input:

How long do you have to sit dear ?

Sample Output:

4

Explanation:

The writing will be:

How long

Do you

Have to

Sit dear ?

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Question 2 : Devil Groups (R->Easy)

Problem Statement  :
There are some groups of devils and they splitted into people to kill them. Devils make People to them left as their group and at last the group with maximum length will be killed. Two types of devils are there namely “@” and “$”
People is represented as a string “P”

Input Format:
First line with the string for input

Output Format:
Number of groups that can be formed.

Constraints:
2<=Length of string<=10^9

Input string
PPPPPP@PPP@PP$PP

Output
7

Explanation
4 groups can be formed
PPPPPP@
PPP@
PP$
PP

Most people in the group lie in group 1 with 7 members.

Question 3 : Airport Authority

Problem Statement -:

In an airport, the Airport authority decides to charge a minimum amount to the passengers who are carrying luggage with them. They set a threshold weight value, say, T, if the luggage exceeds the weight threshold you should pay double the base amount. If it is less than or equal to threshold then you have to pay $1.  

Function Description:

Complete the weightMachine function in the editor below. It has the following parameter(s):

Parameters:

NameTypeDescription
NIntegernumber of luggage
TIntegerweight of each luggage
weights[ ]Integer arraythreshold weight

Returns: The function must return an INTEGER denoting the required amount to be paid.

Constraints:

  • 1 <= N <= 10^5
  • 1 <= weights[i] <= 10^5
  • 1 <= T <= 10^5

Input Format for Custom Testing:

  • The first line contains an integer, N, denoting the number of luggage. 
  • Each line i of the N subsequent lines (where 0 <= i <n) contains an integer describing the weight of ith luggage. 
  • The next line contains an integer, T, denoting the threshold weight of the boundary wall.

Sample Cases:

  • Sample Input 1
    4
    1
    2
    3
    4
    3
  • Sample Output 1
    5
  • Explanation:
    Here all weights are less than threshold weight except the luggage with weight 4 (at index 3) so all pays base fare and it pays double fare.

Question 4 : Simple problem

Problem Statement :

Mr X is a teacher of maths. He came across a very simple problem. In the problem you have to arrange the numbers in an ascending order and calculate the total number of swaps required. The number of swaps must be minimum. But Mr X is busy with some other tasks and you being his favourite student , so he asks you to solve this problem.

Constraints:

1<=T<=100
1<=N<=100
1<=A[ ] <=1000
Examples

Input :
4
4 3 1 2
Output:
2
Explanation: Swap index 0 with 3 and 1 with 2 to form the sorted array {1, 2, 3, 4}.

Input :
5
1 5 4 3 2
Output :
2

Question 5 : Set Bit

Problem Statement  :

You are given an integer, N. You have to turn it into the binary representation of it, and find out how many set bits are there in the binary representation.

Input Format:
The first line contains the integer.

Output Format:
One line containing an integer denoting the number of setbits.

Constraints:
1<=N<=10^9

Sample Input:
8
Output:
1

Output Description:
8 in binary is 1000.

Question 6:

Problem Statement –  Abhijeet is one of those students who tries to get his own money by part time jobs in various places to fill up the expenses for buying books. He is not placed in one place, so what he does, he tries to allocate how much the book he needs will cost, and then work to earn that much money only. He works and then buys the book respectively. Sometimes he gets more money than he needs so the money is saved for the next book. Sometimes he doesn’t. In that time, if he has stored money from previous books, he can afford it, otherwise he needs money from his parents.

Now His parents go to work and he can’t contact them amid a day. You are his friend, and you have to find how much money minimum he can borrow from his parents so that he can buy all the books.

He can Buy the book in any order.

Function Description:

Complete the function with the following parameters:

NameTypeDescription
NIntegerHow many Books he has to buy that day.
EarnArray[ ]Integer arrayArray of his earnings for the ith book
CostArray[ ]Integer arrayArray of the actual cost of the ith book.

Constraints:

  • 1 <= N <= 10^3
  • 1 <= EarnArray[i] <= 10^3
  • 1 <=  CostArray[i] <= 10^3

Input Format:

  • First line contains N.
  • Second N lines contain The ith earning for the ith book.
  • After that N lines contain The cost of the ith book.

Output Format: The minimum money he needs to cover the total expense.

Sample Input 1:

3

[3 4 2]

[5 3 4]

Sample Output 1:

3

Explanation:

At first he buys the 2nd book, which costs 3 rupees, so he saves 1 rupee. Then he buys the 1st book, that takes 2 rupees more. So he spends his stored 1 rupee and hence he needs 1 rupee more. Then he buys the last book.

Question 7:

You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.

Input

  • The single line of the input contains a pair of integers m, s (1 ≤ m ≤ 100, 0 ≤ s ≤ 900) — the length and the sum of the digits of the required numbers.

Output

  • In the output print the pair of the required non-negative integer numbers — first the minimum possible number, then — the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers “-1 -1” (without the quotes).

Examples

  • Input 1
    2 15
  • Output 1
    69 96
  • Input 2
    3 0
  • Output 2
    -1 -1

Question 8: Queries for Count

The task is to determine the number of elements within a specified range in an unsorted array. Given an array of size n, the goal is to count the elements that fall between two given values, i and j, inclusively.
Examples:

Input:
Array: [1, 3, 3, 9, 10, 4]
Range 1: i = 1, j = 4
Range 2: i = 9, j = 12

Output:
For Range 1: 4
For Range 2: 2

Explanation:
In the first query, the numbers within the range 1 to 4 are 1, 3, 3, and 4.
In the second query, the numbers within the range 9 to 12 are 9 and 10.

Question 9: Find the homeless 

Problem Statement -:  There are N Homeless people in the community and N houses in the community. It will be given in the array (people), the height of the person, and in the array house capacity of the house is given.

The government decided to give homes to people on the basis of the following conditions:

  • Priority is given to the people from left to right of the array
  • Each person is allotted to a house if and only if the capacity of the house is greater than or equal to the person’s height
  • Nearby empty Houses are allotted to the person( starting from the extreme left)

You need to find the number of homeless people who have not been allotted any home if the government follows the above conditions. So that government will have an idea of how many people they need to allot homes for next time.

Constraints:

  • 1 <= N <= 10^3
  • 1 <= people[i] <= 10^5
  • 1 <= house[i] <= 10^5

Input Format for Custom Testing:

  • The first line contains an integer, N, denoting the number of  people and number of houses.
  • Each line i of the N subsequent lines (where 0 <= i <= N) contains an integer describing peoplei.
  • Each line i of the N subsequent lines (where 0 <= i <= N) contains an integer describing housei.

Sample Test Cases

  • Sample Input 1
    3  
    4
    2
    7
    3
    5
    10
  • Sample Output 1
    0
  • Explanation
    people=[4,2,7]
    house=[3,5,10]
    People[0] has more priority , from left to right order in houses 5 is the nearest one which fits for people[0]
    people[1]=2 will fit in 3 which is nearer from left
    people[2]=7 will fit in remaining house of capacity of 10
    So no homeless people left so return 0 
  • Sample Input 2
    3
    3
    8
    5
    1
    9
    4
  • Sample Output 2
    2
  • Explanation
    people=[3,8,5]
    house=[1,9,4]
    people[0]=3 can fit in 9 which is nearest from left in array house
    people[1]=8  cannot fit in any home which is left (i.e, 1 and 4)
    people[2]=5 cannot fit in any home which is left (i.e, 1 and 4)
    So return 2,which is number of homeless people

Question 10:

Fountains are installed at every position along a one-dimensional garden of length n. Array locations[] represents the coverage limit of these fountains. The ith fountain (where 1sisn) has a coverage limit of locations[i] that can range from the position max((i – locations[i]), 1) to min((i + locations[i]), n ). In other words, the h fountains do not reach outside the boundaries of the garden. In the beginning,all the fountains are switched off. Determine the minimum number of fountains that need to be activated to cover the n length garden by water.

Example

  • n = 3
  • locations[] = {0, 2, 13, then
    • For position 1: locations[1] = 0, max((1 – 0),
      • 1) to mini (1+0), 3) gives range = 1 to 1
    • For position 2: locations[2] = 2, max((2-2),
      • 1) to min( (2+2), 3) gives range = 1 to 3
    • For position 3: locations[3] = 1, max( (3-1),
      • 1) to min( (3+1), 3) gives range = 2 to 3

For the entire length of this garden to be covered, only the fountain at position 2 needs to be activated.

Function Description

Complete the function fountainActivation in the editor below.

fountainActivation has the following Parameter:

  • int locations[n]: the fountain locations

Returns

  • int: the minimum number of fountains that must be activated

Constraints

  • 1<_n<_ 10^5
  •  O<_locations[i] <_ mini (n,100) (where 1 <_1<_10^5)

► Input Format For Custom Testing

Sample Case 0

Sample Input For Custom Testing

  • 3 ->locations[] size n = 3
  • 1 ->locations[] [1, 1, 1
  • 1 ->Sample Output

Sample Output

  • 1

Explanation

Here, locations = {1, 1, 13

  • For position 1: locations[1] = 1, maxi (1 -1), 1) to min((1+1), 3) gives range = 1 to 2
  • For position 2: locations[2] = 1, max( (2 -1), 1) to min( (2+1), 3) gives range = 1 to 3
  • For position 3: locations[3] = 1, max((3 -1), 1) to min((3+1), 3) gyes range = 2 to 3

If the 2nd fountain is active, the range from position 7 to 3 will be covered. The total number of fountains needed is 1.

FAQs on Intel Coding Questions

Question 1: Is it hard to crack Interview Interview Process?

Candidates who have appeared for Intel Interview process claimed that Technical Interview of Intel is bit Hard because they generally ask questions based on DSA, DBMS, OOPs concept, along with Questions based on Computer Science Fundamentals and Computer System Architecture. etc with other core subjects related to Hardware Component of Computer. 

Question 2: What are steps involved in Intel Recruitment process?

Intel Recruitment Process mainly consists of 3 steps:

  1. Online Aptitude Test
  2. Online Coding Assessment.
  3. Technical Interview
  4. HR Interview
Question 3: Does Intel includes of Group Discussion as the part of Interview ?

Yes, Sometimes Intel also conduct Group Discussion after Both Online Assessments followed by Technical Interview and HR Interview. It totally depends on the No. of Application they receive for Hiring.

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription