0% found this document useful (0 votes)
16 views12 pages

Details of Skill Enhancement Activity: Student Name & USN Semester

The document outlines a skill enhancement activity for a student named Swet Raj, focusing on various programming challenges using the HackerRank platform. It lists multiple problem statements including 'Plus Minus', 'Mini-Max Sum', and 'Time Conversion', along with brief descriptions and example code snippets for each challenge. The document is intended to document the student's progress and the specific tasks undertaken during the skill enhancement activity.

Uploaded by

swetraj20042005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views12 pages

Details of Skill Enhancement Activity: Student Name & USN Semester

The document outlines a skill enhancement activity for a student named Swet Raj, focusing on various programming challenges using the HackerRank platform. It lists multiple problem statements including 'Plus Minus', 'Mini-Max Sum', and 'Time Conversion', along with brief descriptions and example code snippets for each challenge. The document is intended to document the student's progress and the specific tasks undertaken during the skill enhancement activity.

Uploaded by

swetraj20042005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Date: 09-05-25

DETAILS OF SKILL ENHANCEMENT ACTIVITY


Subject Name and Subject code SKILL ENHANCEMENT
Student Name & USN Swet Raj 1AT23CS164
Semester 4
Name of the Tool
HACKER RANK
Used(Hackerank, LeetCode etc)

List the problem statements 1. Plus Minus


2. Staircase
3. Mini-Max Sum
4. Day of the programmer
5. Electronic shop
6. Diagonal Difference
7. String function calculation
8. Cards permutation
9. Time Conversion
10. How Many Substrings?
11. Two two

SIGNATURE OF THE SIGNATURE OF THE


FACULTY HOD
Plus Minus

Given an array of integers, calculate the ratios of its elements that are positive,
negative, and zero. Print the decimal value of each fraction on a new line with 6
places after the decimal. Note: This challenge introduces precision problems.
The test cases are scaled to six decimal places, though answers with absolute
error of up to 10^ -4 are acceptable. Example : arr = [1,1,0, -1,-1]There are n
=5 elements, two positive, two negative and one zero. Their ratios are
2/5=0.400000 , 2

int main() {

int p=0,n=0,z=0,a,i,j;

cin>>j;

for(i=0;i<j;i++){

cin>>a;

if(a>0)

p++;

else if(a<0)

n++;

else

z++;
Mini-Max Sum

Given five positive integers, find the minimum and maximum values that can be calculated
by summing exactly four of the five integers. Then print the respective minimum and
maximum values as a single line of two space-separated long integers. arr = [1,3,5,7,9]
Example The minimum sum is 1 + 3 + 5 + 7 = 16 and the maximum sum is 3 + 5 + 7 + 9
= 24. the function prints 16 24 . Function Description Complete the miniMaxSum function in
the editor below. miniMaxSum has the following

int main(){
LL s[5];
LL d = 0;
for(int i = 0; i < 5; i++){
cin >> s[i];
d += s[i];
}
sort(s,s+5);
cout << d-s[4] << " " << d-s[0] << endl;
}
ELECTRONICS SHOP

Parameters: Returns:
int keyboards[n]: Prices of keyboards int: Maximum amount spent, or -1 if
int drives[m]: Prices of USB drives both items cannot be bought
int b: Budget
Diagonal Difference

Given a square matrix, calculate the absolute difference between the sums of its diagonals. For
example, the square matrix arr is shown below: 1 2 3 4 5 6 9 8 9 The left-to-right diagonal = 1+ 5
+ 9 = 15. .The right to left diagonal = 3 +5 +9 = 17 . Their absolute difference is |15-17| = 2 . .
Function description Complete the diagonal difference function in the editor below.
diagonalDifference takes the following parameter: int arr[n][m]: an array of integers

int main() {
int N;
cin >> N;

int i, j;

int sumdiag1 = 0;
int sumdiag2 = 0;
for(i = 0; i < N; i++){
for(j = 0; j< N; j++)
{
int no;
cin >> no;
if(i == j)
sumdiag1 += no;
if(i+j == N-1)
sumdiag2 += no;
}
}

cout << abs(sumdiag1 - sumdiag2);


return 0;
}
STRING FUNCTION CALCULATION

Input: Output:
A single string s (consisting of lowercase Print the maximum value of f among
English letters). all substrings.
to form a valid sequence. Output the sum modulo 109+710^9 + 7109+7.

Input: Output:
The first line contains an integer nnn. Print the sum of the line numbers of
The second line contains n space- valid permutations.
separated integers (Alice's favorite
Time Conversion

Given a time in 12 -hour AM/PM format, convert it to military (24-hour) time. Note: - [Link]M
on a 12-hour clock is [Link] on a 24-hour clock. - [Link]PM on a 12-hour clock is [Link]
on a 24-hour clock. Example s = '12 : 01: 00PM' Return '[Link]'. s = '12 : 01: 00AM' Return
'[Link]'. Function Description Complete the timeConversion function in the editor below. It
should return a new string representing the input time in 24 hour format. timeConversion h

int main() {

string s;
string h;
int hr;
cin>>s;
hr = ((s[0]-'0')*10)+(s[1]-'0');
if(s[8]=='P'&&s[9]=='M'&& hr ==12) cout<<to_string (hr);
else if(s[8]=='P'&&s[9]=='M') cout<<to_string (hr+12);
else if(s[8]=='A'&&s[9]=='M'&&hr==12) cout<<"00";

else cout<< s[0]<<s[1];

for(int i =2;i<8;i++)
cout<<s[i];
cout<<endl;
return 0;
}
HOW MANY SUBSTRINGS?
Given a string S, for each query with indices l and r, count the number of distinct
substrings in the substring of S between indices l and r (inclusive).
Input Format:
First line: two integers n (length of string) and q
(number of queries). Constraints:
Second line: a string S. String S consists of
Next q lines: each containing two integers l and r, lowercase English letters
representing the indices for the substring. only. 1 ≤ ≤ 1000 1≤n≤1000, 1
Output Format: ≤ ≤ 1000 1≤q≤1000.
For each query, output the number of distinct
substrings in the specified range.
TWO TWO
You are given a string of digits for each test case. For every possible substring,
calculate its "strength," which is the number formed by that substring. If the strength
is a power of two, count it. The task is to count how many such substrings exist in
each test case.
Input Format: Constraints:
The first line contains the integer T, the 1≤T≤100 1 ≤ len ( ) ≤ 1 0 5
number of test cases. 1≤len(A)≤10 5 0 ≤ [ ] ≤
Each of the next T lines contains a string A of 0≤A[i]≤9
digits.

Output Format:
For each test case, print the count of
substrings whose strength is a power of two.

You might also like