import java.util.Arrays;
public class SurpriseDebate {
public static int findLowestRollNumber(int N, int[] A, int K) {
Arrays.sort(A);
int lowestRollNumber = -1;
for (int i = 0, j = N - 1; i < j; i++, j--) {
int sum = A[i] + A[j];
if (sum % K == 0) {
lowestRollNumber = Math.min(A[i], A[j]);
} else {
break;
}
}
if (lowestRollNumber == -1 && N % 2 == 1 && A[N / 2] * 2 % K == 0) {
lowestRollNumber = A[N / 2];
}
return lowestRollNumber;
}
public static void main(String[] args) {
int N = 5;
int[] A = {12, 1, 3, 5, 44};
int K = 6;
int result = findLowestRollNumber(N, A, K);
System.out.println(result);
}
}
Share @Coding_000❤️✅
public class SurpriseDebate {
public static int findLowestRollNumber(int N, int[] A, int K) {
Arrays.sort(A);
int lowestRollNumber = -1;
for (int i = 0, j = N - 1; i < j; i++, j--) {
int sum = A[i] + A[j];
if (sum % K == 0) {
lowestRollNumber = Math.min(A[i], A[j]);
} else {
break;
}
}
if (lowestRollNumber == -1 && N % 2 == 1 && A[N / 2] * 2 % K == 0) {
lowestRollNumber = A[N / 2];
}
return lowestRollNumber;
}
public static void main(String[] args) {
int N = 5;
int[] A = {12, 1, 3, 5, 44};
int K = 6;
int result = findLowestRollNumber(N, A, K);
System.out.println(result);
}
}
Share @Coding_000❤️✅
🔥2❤1
public class PizzaParty {
public static int sumOfDigits(int number) {
int sum = 0;
while (number > 0) {
sum += number % 10;
number /= 10;
}
return sum;
}
public static int minFriends(int N, int Y) {
for (int i = Y; i <= N; i++) {
if (N % i == 0) {
return sumOfDigits(i);
}
}
return -1;
}
public static void main(String[] args) {
int input1 = 18;
int input2 = 4;
int output = minFriends(input1, input2);
System.out.println("Output: " + output);
}
}
Pizza party in java
public static int sumOfDigits(int number) {
int sum = 0;
while (number > 0) {
sum += number % 10;
number /= 10;
}
return sum;
}
public static int minFriends(int N, int Y) {
for (int i = Y; i <= N; i++) {
if (N % i == 0) {
return sumOfDigits(i);
}
}
return -1;
}
public static void main(String[] args) {
int input1 = 18;
int input2 = 4;
int output = minFriends(input1, input2);
System.out.println("Output: " + output);
}
}
Pizza party in java
👍1
public class NoahOperations {
public static int[] findMaxProductPair(int N, int[] A) {
int[] result = new int[2];
int maxProduct = Integer.MIN_VALUE;
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
if (A[i] + A[j] == 18 && A[i] > A[j]) {
int product = A[i] * A[j];
if (product > maxProduct) {
maxProduct = product;
result[0] = A[i];
result[1] = A[j];
}
}
}
}
return result;
}
public static void main(String[] args) {
int input1 = 8;
int[] input2 = {11, 12, 2, 8, 10, 11, 9, 8};
int[] output = findMaxProductPair(input1, input2);
System.out.println("Output: (" + output[0] + ", " + output[1] + ")");
}
}
public static int[] findMaxProductPair(int N, int[] A) {
int[] result = new int[2];
int maxProduct = Integer.MIN_VALUE;
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
if (A[i] + A[j] == 18 && A[i] > A[j]) {
int product = A[i] * A[j];
if (product > maxProduct) {
maxProduct = product;
result[0] = A[i];
result[1] = A[j];
}
}
}
}
return result;
}
public static void main(String[] args) {
int input1 = 8;
int[] input2 = {11, 12, 2, 8, 10, 11, 9, 8};
int[] output = findMaxProductPair(input1, input2);
System.out.println("Output: (" + output[0] + ", " + output[1] + ")");
}
}
👍1🔥1🥰1
Equivalent code
Python3 ✅
Python3 ✅
👍1
https://app.joinsuperset.com/join/#/signup/student?jp=2332640c-d0cb-4e85-81bf-994b72d13611
Hexaware hiring for 2024 check eligible and branch and then apply✅
Hexaware hiring for 2024 check eligible and branch and then apply✅
👍1
def integer_to_roman(num):
arabic = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
roman = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]
if num <= 0 or num > 1000:
print("Invalid input. Please enter a positive integer between 1 and 1000.")
return
roman_numeral = ""
for i in range(len(arabic)):
while num >= arabic[i]:
roman_numeral += roman[i]
num -= arabic[i]
return roman_numeral
# Example usage:
input_number = 18
result = integer_to_roman(input_number)
print(f"Roman numeral equivalent: {result}")
IBM EXAM CODE ✅
Share @Coding_000❤️👨💻
arabic = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
roman = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]
if num <= 0 or num > 1000:
print("Invalid input. Please enter a positive integer between 1 and 1000.")
return
roman_numeral = ""
for i in range(len(arabic)):
while num >= arabic[i]:
roman_numeral += roman[i]
num -= arabic[i]
return roman_numeral
# Example usage:
input_number = 18
result = integer_to_roman(input_number)
print(f"Roman numeral equivalent: {result}")
IBM EXAM CODE ✅
Share @Coding_000❤️👨💻
🔥1🥰1
Any one want projects -mini or Major 😊 Unique project💥💥
Domain AI/ML
contact -@ILOVEU_143 ❤️
Anyone need help in GRE and TOFEL, GMAT, DUOLINGO Exam help 👨💻👨💻
SOP , LOR, Resume ✍📝
Note -paid 🤑
share✅ share ✅@Coding_000
https://t.me/Finalyearprojectcse_Ml
Domain AI/ML
contact -@ILOVEU_143 ❤️
Anyone need help in GRE and TOFEL, GMAT, DUOLINGO Exam help 👨💻👨💻
SOP , LOR, Resume ✍📝
Note -paid 🤑
share✅ share ✅@Coding_000
https://t.me/Finalyearprojectcse_Ml
Telegram
Final Year Projects | Cse projects | AI /ML Projects
Main channel https://t.me/Coding_000
Contact Admin 👉 @ILOVEU_143 for booking your exam slots
Web- https://coding000.github.io/Projects/
💯% clearance in any placement exams
OffCampus -https://t.me/Offcampus_000
Discussion- https://t.me/exams_discussion
Contact Admin 👉 @ILOVEU_143 for booking your exam slots
Web- https://coding000.github.io/Projects/
💯% clearance in any placement exams
OffCampus -https://t.me/Offcampus_000
Discussion- https://t.me/exams_discussion
👍2
How many u have Tcs Codevita...?
Hit like...👍❤️
Hit like...👍❤️
👍9🌚1
TCS CODEVITA✅
PYTHON3
def toggle(num):
result = ""
for bit in num:
if bit == "0":
result += "1"
else:
result += "0"
return result
def get_max_sum(arr, k):
max_val = max(arr)
max_index = arr.index(max_val)
left = max(0, max_index-k)
right = min(len(arr)-1, max_index+k)
selected = arr[left:max_index+1] + arr[max_index:right+1]
arr = [x for x in arr if x not in selected]
return sum(selected), arr
# Input
arr = list(map(int, input().split()))
a1, b1 = input().split()
a2, b2 = input().split()
k = int(input())
sum1, sum2 = 0, 0
while arr:
s1, arr = get_max_sum(arr, k)
sum1 += s1
if not arr:
break
s2, arr = get_max_sum(arr, k)
sum2 += s2
if sum1 > sum2:
a1 = toggle(a1)
b2 = toggle(b2)
else:
a2 = toggle(a2)
b1 = toggle(b1)
xor1 = int(a1, 2) ^ int(b1, 2)
xor2 = int(a2, 2) ^ int(b2, 2)
if xor1 > xor2:
print("Rahul")
elif xor2 > xor1:
print("Rupesh")
else:
print("both")
who is lucky✅
TCS codevita
Python3
@coding_000 ✅
PYTHON3
def toggle(num):
result = ""
for bit in num:
if bit == "0":
result += "1"
else:
result += "0"
return result
def get_max_sum(arr, k):
max_val = max(arr)
max_index = arr.index(max_val)
left = max(0, max_index-k)
right = min(len(arr)-1, max_index+k)
selected = arr[left:max_index+1] + arr[max_index:right+1]
arr = [x for x in arr if x not in selected]
return sum(selected), arr
# Input
arr = list(map(int, input().split()))
a1, b1 = input().split()
a2, b2 = input().split()
k = int(input())
sum1, sum2 = 0, 0
while arr:
s1, arr = get_max_sum(arr, k)
sum1 += s1
if not arr:
break
s2, arr = get_max_sum(arr, k)
sum2 += s2
if sum1 > sum2:
a1 = toggle(a1)
b2 = toggle(b2)
else:
a2 = toggle(a2)
b1 = toggle(b1)
xor1 = int(a1, 2) ^ int(b1, 2)
xor2 = int(a2, 2) ^ int(b2, 2)
if xor1 > xor2:
print("Rahul")
elif xor2 > xor1:
print("Rupesh")
else:
print("both")
who is lucky✅
TCS codevita
Python3
@coding_000 ✅
👍1🔥1
def convert(expression):
stack = []
tokens = expression.split()
for token in reversed(tokens):
if is_operand(token):
stack.append(int(token))
elif is_operator(token):
if len(stack) < 2:
return float('-inf')
operand2 = stack.pop()
operand1 = stack.pop()
if token == "+":
stack.append(operand1 + operand2)
elif token == "-":
stack.append(operand1 - operand2)
elif token == "*":
stack.append(operand1 * operand2)
elif token == "/":
stack.append(operand1 / operand2)
elif token == "^":
stack.append(operand1 ** operand2)
elif token == "%":
stack.append(operand1 % operand2)
if len(stack) != 1:
return float('-inf')
return stack.pop()
def is_operand(token):
return token.lstrip('-').isdigit()
def is_operator(token):
return token in {"+", "-", "*", "/", "^", "%"}
def main():
prefix = input()
word_map = {
"zero": "0", "one": "1", "two": "2", "three": "3", "four": "4",
"five": "5", "six": "6", "seven": "7", "eight": "8", "nine": "9",
"mul": "*", "add": "+", "sub": "-", "div": "/", "rem": "%", "pow": "^"
}
words = prefix.split()
real_prefix = ""
for word in words:
if word in word_map:
real_prefix += word_map[word] + " "
continue
small_words = word.split("c")
for s in small_words:
if s:
if s not in word_map:
print("expression evaluation stopped invalid words present")
return
real_prefix += word_map[s]
real_prefix += " "
infix = convert(real_prefix)
if infix == float('-inf'):
print("expression is not complete or invalid")
else:
print(int(infix))
if name == "main":
main()
No more Shuffle Code
Fully Passed 😍👍👍
TCS CODEVITA SOLUTIONS
PYTHON3
No more shuffle code
stack = []
tokens = expression.split()
for token in reversed(tokens):
if is_operand(token):
stack.append(int(token))
elif is_operator(token):
if len(stack) < 2:
return float('-inf')
operand2 = stack.pop()
operand1 = stack.pop()
if token == "+":
stack.append(operand1 + operand2)
elif token == "-":
stack.append(operand1 - operand2)
elif token == "*":
stack.append(operand1 * operand2)
elif token == "/":
stack.append(operand1 / operand2)
elif token == "^":
stack.append(operand1 ** operand2)
elif token == "%":
stack.append(operand1 % operand2)
if len(stack) != 1:
return float('-inf')
return stack.pop()
def is_operand(token):
return token.lstrip('-').isdigit()
def is_operator(token):
return token in {"+", "-", "*", "/", "^", "%"}
def main():
prefix = input()
word_map = {
"zero": "0", "one": "1", "two": "2", "three": "3", "four": "4",
"five": "5", "six": "6", "seven": "7", "eight": "8", "nine": "9",
"mul": "*", "add": "+", "sub": "-", "div": "/", "rem": "%", "pow": "^"
}
words = prefix.split()
real_prefix = ""
for word in words:
if word in word_map:
real_prefix += word_map[word] + " "
continue
small_words = word.split("c")
for s in small_words:
if s:
if s not in word_map:
print("expression evaluation stopped invalid words present")
return
real_prefix += word_map[s]
real_prefix += " "
infix = convert(real_prefix)
if infix == float('-inf'):
print("expression is not complete or invalid")
else:
print(int(infix))
if name == "main":
main()
No more Shuffle Code
Fully Passed 😍👍👍
TCS CODEVITA SOLUTIONS
PYTHON3
No more shuffle code
🔥1🥰1
Share our channel screenshot in large groups ✅✅✅✅✅
For remaining coding answers 🏃🏃🏃🏃
For remaining coding answers 🏃🏃🏃🏃
❤1👍1
import numpy as np
def find_widest_valley(n, A, B):
def surface_equation(x):
return sum(np.sin(a*x + b) for a, b in zip(A, B))
def find_local_maxima():
maxima = []
for i in range(1, n-1):
if surface_equation(i-1) < surface_equation(i) > surface_equation(i+1):
maxima.append(i)
return maxima
def find_valley_width(left, right):
return right - left
maxima = find_local_maxima()
widest_valley_width = 0
widest_valley_index = 0
for i in range(len(maxima)-1):
left_maxima = maxima[i]
right_maxima = maxima[i+1]
current_valley_width = find_valley_width(left_maxima, right_maxima)
if current_valley_width > widest_valley_width:
widest_valley_width = current_valley_width
widest_valley_index = left_maxima + 1
return widest_valley_index
# Input parsing
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# Output
print(find_widest_valley(n, A, B))
Water resources code ✅✅✅✅
Full passsd ✅✅
Please share @Coding_000❤️
Water Resources Code
TCS CODEVITA
PYTHON
def find_widest_valley(n, A, B):
def surface_equation(x):
return sum(np.sin(a*x + b) for a, b in zip(A, B))
def find_local_maxima():
maxima = []
for i in range(1, n-1):
if surface_equation(i-1) < surface_equation(i) > surface_equation(i+1):
maxima.append(i)
return maxima
def find_valley_width(left, right):
return right - left
maxima = find_local_maxima()
widest_valley_width = 0
widest_valley_index = 0
for i in range(len(maxima)-1):
left_maxima = maxima[i]
right_maxima = maxima[i+1]
current_valley_width = find_valley_width(left_maxima, right_maxima)
if current_valley_width > widest_valley_width:
widest_valley_width = current_valley_width
widest_valley_index = left_maxima + 1
return widest_valley_index
# Input parsing
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# Output
print(find_widest_valley(n, A, B))
Water resources code ✅✅✅✅
Full passsd ✅✅
Please share @Coding_000❤️
Water Resources Code
TCS CODEVITA
PYTHON
🔥1
def toggle(num):
result = ""
for bit in num:
if bit == "0":
result += "1"
else:
result += "0"
return result
def get_max_sum(arr, k):
max_val = max(arr)
max_index = arr.index(max_val)
left = max(0, max_index-k)
right = min(len(arr)-1, max_index+k)
selected = arr[left:max_index+1] + arr[max_index:right+1]
arr = [x for x in arr if x not in selected]
return sum(selected), arr
# Input
arr = list(map(int, input().split()))
a1, b1 = input().split()
a2, b2 = input().split()
k = int(input())
sum1, sum2 = 0, 0
while arr:
s1, arr = get_max_sum(arr, k)
sum1 += s1
if not arr:
break
s2, arr = get_max_sum(arr, k)
sum2 += s2
if sum1 > sum2:
a1 = toggle(a1)
b2 = toggle(b2)
else:
a2 = toggle(a2)
b1 = toggle(b1)
xor1 = int(a1, 2) ^ int(b1, 2)
xor2 = int(a2, 2) ^ int(b2, 2)
if xor1 > xor2:
print("Rahul",end="")
elif xor2 > xor1:
print("Rupesh",end="")
else:
print("both",end="")
WHO IS LUCKY CODE✅
TCS CODEVITA
PYTHON3
Share @coding_000❤️
result = ""
for bit in num:
if bit == "0":
result += "1"
else:
result += "0"
return result
def get_max_sum(arr, k):
max_val = max(arr)
max_index = arr.index(max_val)
left = max(0, max_index-k)
right = min(len(arr)-1, max_index+k)
selected = arr[left:max_index+1] + arr[max_index:right+1]
arr = [x for x in arr if x not in selected]
return sum(selected), arr
# Input
arr = list(map(int, input().split()))
a1, b1 = input().split()
a2, b2 = input().split()
k = int(input())
sum1, sum2 = 0, 0
while arr:
s1, arr = get_max_sum(arr, k)
sum1 += s1
if not arr:
break
s2, arr = get_max_sum(arr, k)
sum2 += s2
if sum1 > sum2:
a1 = toggle(a1)
b2 = toggle(b2)
else:
a2 = toggle(a2)
b1 = toggle(b1)
xor1 = int(a1, 2) ^ int(b1, 2)
xor2 = int(a2, 2) ^ int(b2, 2)
if xor1 > xor2:
print("Rahul",end="")
elif xor2 > xor1:
print("Rupesh",end="")
else:
print("both",end="")
WHO IS LUCKY CODE✅
TCS CODEVITA
PYTHON3
Share @coding_000❤️
🔥1
This media is not supported in your browser
VIEW IN TELEGRAM
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int max_efficiency(vector<int>& numbers) {
sort(numbers.begin(), numbers.end());
int n = numbers.size();
int max_efficiency = 0;
for (int i = 0; i < n; ++i) {
int efficiency = 0;
for (int j = i; j < n; ++j) {
efficiency += numbers[j] * (j - i + 1);
}
max_efficiency = max(max_efficiency, efficiency);
}
return max_efficiency;
}
int main() {
// Input parsing
int n;
cin >> n;
vector<int> numbers(n);
for (int i = 0; i < n; ++i) {
cin >> numbers[i];
}
// Output
int result = max_efficiency(numbers);
cout << (result >= 0 ? result : 0) << endl;
return 0;
}
Sports day codee in C+++
Now Share
Sport Day Code
Tcs codevita
Fully passsd ✅✅✅✅✅
#include <vector>
#include <algorithm>
using namespace std;
int max_efficiency(vector<int>& numbers) {
sort(numbers.begin(), numbers.end());
int n = numbers.size();
int max_efficiency = 0;
for (int i = 0; i < n; ++i) {
int efficiency = 0;
for (int j = i; j < n; ++j) {
efficiency += numbers[j] * (j - i + 1);
}
max_efficiency = max(max_efficiency, efficiency);
}
return max_efficiency;
}
int main() {
// Input parsing
int n;
cin >> n;
vector<int> numbers(n);
for (int i = 0; i < n; ++i) {
cin >> numbers[i];
}
// Output
int result = max_efficiency(numbers);
cout << (result >= 0 ? result : 0) << endl;
return 0;
}
Sports day codee in C+++
Now Share
Sport Day Code
Tcs codevita
Fully passsd ✅✅✅✅✅
🔥1
#include <iostream>
#include <vector>
#include <algorithm>
int max_points(std::vector<int>& chocolates, int initial) {
std::sort(chocolates.begin(), chocolates.end());
int points = 0;
int max_points = 0;
for (int i = 0; i < chocolates.size(); ++i) {
if (chocolates[i] <= initial) {
initial -= chocolates[i];
points++;
max_points = std::max(max_points, points);
} else {
break;
}
}
return max_points;
}
int main() {
int n;
std::cin >> n; // Number of chocolates
std::vector<int> chocolates(n);
for (int i = 0; i < n; ++i) {
std::cin >> chocolates[i];
}
int initial_chocolates;
std::cin >> initial_chocolates; // Initial chocolates Bittu has
int result = max_points(chocolates, initial_chocolates);
std::cout << result;
return 0;
}
Chocolates code ✅✅
Share @Coding_000❤️
#include <vector>
#include <algorithm>
int max_points(std::vector<int>& chocolates, int initial) {
std::sort(chocolates.begin(), chocolates.end());
int points = 0;
int max_points = 0;
for (int i = 0; i < chocolates.size(); ++i) {
if (chocolates[i] <= initial) {
initial -= chocolates[i];
points++;
max_points = std::max(max_points, points);
} else {
break;
}
}
return max_points;
}
int main() {
int n;
std::cin >> n; // Number of chocolates
std::vector<int> chocolates(n);
for (int i = 0; i < n; ++i) {
std::cin >> chocolates[i];
}
int initial_chocolates;
std::cin >> initial_chocolates; // Initial chocolates Bittu has
int result = max_points(chocolates, initial_chocolates);
std::cout << result;
return 0;
}
Chocolates code ✅✅
Share @Coding_000❤️
👍1