Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
HWI or HackWithInfy is a coding competition started in 2018 by Infosys for young engineers studying in their second year, pre-final year and final year. The program is specifically designed to instil a culture of rapid problem-solving and innovative thinking in students early in their academic careers. Through this competition, Infosys chooses the best coders across the country. Since this competition is all over India, its difficulty level is relatively high, but the winner's prize is delightful.
Round 1: In this round, there are three coding questions ranging from easy to hard difficulty level, to be completed in 3 hours. This is an online round and usually takes place on any online coding platform.
Round 2 (Grand Finale): Out of all, the top 100 participants are selected for this round. This is the final round which consists of a 48 hours hackathon. This round is conducted in any of the Infosys campuses.
There is no negative marking in both rounds.
Eligibility Criteria
The eligibility criteria for HWI is as follows:
Your age must be at least 18 years on the date of registration for the competition.
You must be doing your graduation in B.E./ B.Tech/ M.E./ M.Tech courses in Computer Science or Information Technology.
Your percentage should be greater than 60% and CGPA above 6.5 in 10th, 12th, UG or PG.
You must not have any active backlogs.
This blog will mainly focus on Round 1.
Round 1
In round 1, 3 coding questions are there, to be completed in 3 hours. The difficulty level of these questions ranges from easy to high. The participants who are able to solve all three questions earn a chance of getting selected. However, the selection criteria depend on the number and performance of the participants.
Below is the list of topics from which we expect coding questions of this round.
Problem Statement: There are three stone piles. The first pile is made up of a stones, the second of b stones, and the third of c stones. You must select one of the piles and move the stones from it to the other two piles; specifically, if the chosen pile initially contained s stones, you must select an integer k (0<=k<=s), move k stones from the chosen pile to one of the remaining two piles, and s-k stones to the other remaining pile. Determine whether the two remaining piles (in any order) can contain x stones and y stones after performing this action.
Let’s see the desired input and output for this problem-
Input
Output
Now, we will look for some sample test cases to better understand the problem.
Sample Input
Sample Output
4 (Number of Test Cases)
1 2 3 2 4
YES
3 2 5 6 5
NO
2 4 2 6 2
YES
6 5 2 12 1
NO
Below is a little explanation of some test cases:
Test Case 1: Take the two stones from the second pile and place one on the first pile and the other on the third pile.
Test Case 2: You don’t have enough stones.
Test Case 3: Choose the first pile and place all of the stones from it on the second pile.
At last, some constraints for this problem are given. For getting a full score, our code must satisfy these constraints.
Constraints
Approach
To solve this problem, let us first sort the given piles (a,b,c) in ascending order of the number of stones. Also, sort the piles x and y (x,y).
The first condition that must be met is that the number of stones at the beginning and end remain the same because none of the stones is thrown away; they are simply rearranged into different piles. Condition 1: a + b + c = x + y
The second condition that must be met is that the size of a pile can only increase and cannot decrease. So, if the number of stones in the smallest pile at the start is greater than the number in the smallest pile at the end, we will fail to meet our goal. Condition 2: a <= x
The third condition that must be met is similar to the second condition. If the number of stones in the second smallest pile at the start is greater than the number in the second smallest pile at the end, we will fail to meet our goal. Condition 3: b <= x
The above three conditions are sufficient to have a solution. For example, consider the third pile of stone (c) with the excess number of stones. We will move some stones from this pile to the first pile and some to the second pile. Such a move will occur because the total number of stones is the same, and the number of stones in both remaining piles can only increase.
Code
Below is the code for this question in C++.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll t;
cin>>t;
while(t--) {
ll a,b,c,x,y;
cin>>a>>b>>c>>x>>y;
if(a>b)
swap(a,b);
if(a>c)
swap(a,c);
if(b>c)
swap(b,c);
if(x>y)
swap(x,y);
if(a+b+c != x+y || a>x || b>y)
cout<<"NO\n";
else
cout<<"YES\n";
}
}
You can also try this code with Online C++ Compiler
Problem Statement: Ramu has N different types of dishes arranged in a row: A1,A2,...,AN, where Ai denotes the type of the ith dish. He wants to select as many dishes as possible from the given list while meeting two criteria:
He can only order one type of dish.
He cannot place two dishes next to each other.
Ramu wishes to know which type of dish he should select to get the greatest number of dishes.
As an example:
Given N = 9 and A = [1,2,2,1,2,1,1,1,1,1,1],
Ramu can only select four dishes for type 1. A1, A4, A7 and A9 are examples of four dishes of type 1. Ramu can only select two dishes for type 2. One option is to use A3 and A5. In this case, Ramu should select type 1, which allows him to select more dishes.
Let’s see the desired input and output for this problem-
Input
Output
Now, we will look for some sample test cases to better understand the problem.
Sample Input
Sample Output
3 (Number of Test Cases)
5
1 2 2 1 2
1
6
1 1 1 1 1 1
1
8
1 2 2 2 3 4 2 1
2
Below is a little explanation of some test cases:
Test case 1: For both types 1 and 2, Ramu can select no more than two dishes. When there are multiple answers, we choose the smallest one. As a result, the answer will be 1.
Test case 2: There are only dishes of type 1 available. So the correct answer is 1.
Test case 3: Ramu can select no more than two dishes for type 1. He has three options for type 2. Ramu may select the only dish available for types 3 and 4. As a result, the maximum is in type 2, and the answer is 2.
At last, some constraints for this problem are given. For getting a full score, our code must satisfy these constraints.
Constraints
Approach
In this problem, we need to find a valid subsequence of dishes, to define a valid subsequence as
It must not be empty.
The subsequence's values should all be the same.
In the given sequence, no two values are chosen that are adjacent.
To achieve these goals, we will first store the frequencies of each distinct element. While storing the frequency, we need to ensure that we need not increase our frequency count if two values are adjacent.
After storing all the frequencies, we just need to find the digit with the maximum frequency. If there are multiple digits, we will choose the smallest one.
Code
Below is the code for this question in C++.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n, freq[1001]={0};
cin>>n;
int last=-1, x;
bool take=1;
for(int i=0; i<n; ++i)
{
cin>>x;
if(last==x)
take=!take;
else
take=1;
if(take) ++freq[x];
last=x;
}
int ans=0, mfreq=0;
for(int i=1; i<=1000; ++i)
if(freq[i]>mfreq)
{
ans=i; mfreq=freq[i];
}
cout<<ans<<"\n";
}
return 0;
}
You can also try this code with Online C++ Compiler
Problem Statement: Altaf has recently discovered and is fascinated by number bases. Altaf discovered that new digit symbols must be introduced for bases greater than ten and that the convention is to use the first few letters of the English alphabet. In base 16, for example, the digits are 0123456789ABCDEF. Altaf believed this scheme was unsustainable; the English alphabet only has 26 letters, so this scheme could only work up to base 36. On the other hand, Altaf is very creative and can simply invent new digit symbols when he needs them. (Altaf is a very inventive person).
Altaf also noticed that all positive integers in base 2 begin with the digit 1! This is, however, the only base where this is true. Altaf naturally wonders: Given an integer N, how many bases B exist such that the base-b representation of N begins with a 1?
Let’s see the desired input and output for this problem-
Input
Output
Now, we will look for some sample test cases given to better understand the problem.
Sample Input
Sample Output
4 (Number of Test Cases)
6
4
9
7
11
8
24
14
Below is a little explanation of some test cases:
Test Case 1: 6 has a leading digit 1 in bases 2, 4, 5 and 6: 610 = 1102 = 124 = 115 = 106.
At last, some constraints for this problem are given. For getting a full score, our code must satisfy these constraints.
Constraints
Approach
Assume that the base under consideration, B, has (K+1) digits. This type of base can represent numbers in the range: [B^K, B^(K + 1)). We need the first digit to be equal to 1. The base B of number N can start with 1 if and only if it is in the range [B^K, 2.B^K). This means that floor(N/2) < B^K <= N, which is equivalent to floor(N/2^1/K) < B <= N^1/K. We can now find the bases B that we need for each value of K - that is, the values of B satisfying the inequality. Because the maximum N value in the given problem is 10^12, the maximum possible length of the base is 40.
Code
Below is the code for this question in C++.
#include<bits/stdc++.h>
using namespace std;
vector<long long int>v[47];
int main()
{
long long int i,j;
for(i=2;i<=(int)1e6;i++)
{
long long int tem=i;
for(j=2;j<=40;j++)
{
tem=tem*i;
if(tem>(long long int)1e12)
break;
v[j].push_back(tem);
}
}
int t;
scanf("%d",&t);
while(t--)
{
long long int m;
scanf("%lld",&m);
if(m==1)
{
printf("INFINITY\n");
continue;
}
long long int ans=(m+1)/2;
long long int p=m/2+1;
for(i=2;i<=40;i++)
ans=ans+(lower_bound(v[i].begin(),v[i].end(),m+1)-lower_bound(v[i].begin(),v[i].end(),p));
printf("%lld\n",ans);
}
return 0;
}
You can also try this code with Online C++ Compiler
Round 1: If you become a top performer in round 1 then you will get-
Pre Placement interview opportunities for niche technical roles.
Paid internships at Infosys.
Chance to become a campus ambassador at your college.
Opportunity to work on difficult problems and mentorship from technology leaders.
The top 100 participants will get to compete in the Grand Finale round.
Round 2: There are various exciting prizes for the round 2 winners.
The winner of the HWI will get Rs 2 lakh while first and second runner ups will get Rs 1 lakh and Rs 50,000, respectively.
The good rankers will get an opportunity to interview for the system engineer and power programming roles at Infosys.
Frequently asked questions
How to register for HWI? To register for HWI, the students need to download the InfyTQ app from Google Play Store or register on the official HackWithInfy website. Then you have to fill in all the required details like name, email etc.
Who can appear for HWI? All the students in either their second year, pre-final year or final year doing the course B.Tech/ B.E/ M.Tech/ M.E can appear for HWI.
How many rounds are there in HWI? There are two rounds in HWI. Round 1 consists of a 3-hour online coding round. Round 2 consists of a 48-hour hackathon.
What are the rewards for round 1? The rewards for round 1 include paid internships, campus ambassadors, work on live projects, pre-placement interviews. Moreover, the top 100 participants will compete in the Grand Finale round.
What are the rewards for round 2? The rewards for round 2 include Rs 2 lakh, Rs 1.5 lakh, Rs 50,000 for the winner, first runner up and second runner up, respectively. Moreover, the good rankers will get an opportunity to interview for the system engineer and power programming roles at Infosys.
Key Takeaways
In this blog, we went through the most asked questions in HWI for round 1 in detail. Besides the coding questions, we also discussed the HWI paper pattern, eligibility criteria, syllabus for round 1 and the rewards of HWI.
Try the Infosys Test Series by Coding Ninjas if you want to prepare for HackWithInfy (HWI).