Skip to main content

TechGig Code Gladiators 2023 Coding Solutions

TechGig Open Coding Round Code Gladiators 2023 Answers



Round 1  - Problem 1

Forest Fire Coding Solution

Figure out the minimum energy level P such that they can get exactly X animals to transport. 

Test Case:
5 4 
1 3 2 4 5

Output:
2

Coding Solution in Python 3:


from bisect import bisect_left
#Telegram - @PLACEMENTLELO
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
#Telegram - @PLACEMENTLELO
if n - bisect_left(a, a[n-m]) != m:
print(-1)
else:
print(a[n - m])
#Telegram - @PLACEMENTLELO
-------------------------------------------

Round 2  - Problem 2

The Magic Coding Solution

The cost of using wand for operation on element equal to absolute difference between value of element and desired value after operation.


Test Case:
5 3
1 2 3 4 5
5 2 1

Output:
10 7 10

Coding Solution in Python 3:


from bisect import bisect_left
#Telegram - @PLACEMENTLELO
n, m = map(int, input().split())
A = list(map(int, input().split()))
Q = list(map(int, input().split()))
A.sort()
#Telegram - @PLACEMENTLELO
C = [0] * (n + 1)
for i in range(n):
C[i + 1] = C[i] + A[i]
#Telegram - @PLACEMENTLELO
def sum(l, r):
return C[r+1] - C[l]

#Telegram - @PLACEMENTLELO
for q in Q:
p = bisect_left(A, q)
print(sum(p, n-1) - sum(0, p-1) + q * (2 * p - n), end=' ')
#Telegram - @PLACEMENTLELO

-------------------------------------------
Share this with your friends and help them !!



Comments

Post a Comment

Popular posts from this blog

Program for Oscillating Prices of Chakri Coding Problem

Oscillating Prices of Chakri Diwali is here. While everyone here is busy texting "Happy Diwali" wishes to everybody else, Coder has some other plans and wants to earn some money this season. Now, the Apex court has allowed the sale of only green crackers this Diwali. Out of all green crackers, "Chakri" is most popular. Because of the irregular supply of "Chakri", the price of "Chakri" is oscillating daily. Coder saw a business opportunity in this. He/She got a price list for coming N days from an insider in the market union. Prices in the list are for 1 unit of a large packet of "Chakri". Each large packet contains 100 units of Chakri. Now, due to financial limitations, Coder can transact only 1 large packet (100 units of "Chakri") in the market. You have to tell maximum profit possible, given that he/she can transact atmost one time. Note: 1. Transaction refers to the act of buying and selling.       2. "Chakri" can...

Alex and his Array code TechGig Geek Goddess 2023

 Alex and his Array code TechGig Geek Goddess 2023: 100% Working Code uploaded on Youtube: https://youtu.be/6cn7nNtSiKo 100% Working Code uploaded on Telegram: https://telegram.me/PLACEMENTLELO Alex and his array (100 Marks) Meet Alex, a bright student who is dealing with an array challenge today. He has been given an array a1, a2, ..., aN of length N. The intriguing aspect of this challenge is that Alex can perform various operations on the array elements. In a single operation, Alex is allowed to choose two indices l and r, where 1 ≤ l ≤ r ≤ n. He can then multiply all the elements in the subarray [al, al+1, ..., ar] by -1, effectively reversing their signs. Being pressed for time as he is running late for school, Alex is seeking your assistance in determining the maximum possible sum of numbers in the array. Additionally, he is eager to find out the minimum number of operations required to achieve this maximum sum. Input Format The first line contains an integer N, the...