Byte Battle 2.0 Solutions
Byte Battle 2.0 Solutions
Return all lonely numbers seperated by space along with sorted in ascending order.
Input Format
Constraints
Output Format
Sample Input 0
10 6 5 8
Sample Output 0
8 10
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
Arrays.sort(nums);
Date – 12th Sept, 2024
int n = nums.length;
isLonely = false;
isLonely = false;
if (isLonely) {
lonelyNumbers.add(nums[i]);
return lonelyNumbers;
int n = scanner.nextInt();
Date – 12th Sept, 2024
nums[i] = scanner.nextInt();
scanner.close();
}
Date – 12th Sept, 2024
Ash and KT Pandey makes alternating moves. Ash makes first move, KT Pandey makes the second
move, Ash makes the third move and so on...
During each move, the current player must choose two different adjacent characters of string s and
delete them. For example, if s=1011001 then the following moves are possible:
If a player can't make any move, they lose. Both players play optimally. You have to determine if Ash
can win.
Input Format
Only line of each test case consist of a string s(consists of 0s and 1s)
Constraints
1<=t<=1000
1<=|s|<=100
Output Format
Sample Input 0
Date – 12th Sept, 2024
3
01
1111
0011
Sample Output 0
YES
NO
NO
Explanation 0
In the first test case after Ash move string s become empty and KT Pandey can not make any move.
In the second test case Ash can not make any move initially.
In the third test case after Ash move string s turn into 01 . Then, after KT Pandey move string s
become empty and Ash can not make any move.
import java.util.Scanner;
int t = scanner.nextInt();
String s = scanner.nextLine();
int count0 = 0;
int count1 = 0;
if (c == '0') {
count0++;
} else if (c == '1') {
count1++;
if (Math.min(count0, count1) % 2 == 1) {
System.out.println("YES");
} else {
System.out.println("NO");
scanner.close();
}
Date – 12th Sept, 2024
Given a list of integers where each integer represents the excitement level of a destination, and an
integer representing the target excitement level Raj wants to achieve, your task is to return the
indices of the two destinations such that their combined excitement level equals the target.
Note: Each input will have exactly one solution, and Raj will not visit the same destination twice. The
output indices can be in any order.
Input Format
• List Item An array nums of n integers where nums[i] represents the excitement level of the i-
th destination.
• List Item An integer target representing the total excitement level Raj wants to achieve by
visiting exactly two destinations.
Constraints
Output Format
• List Item Return an array containing the two indices of the destinations Raj should visit.
Sample Input 0
1967
Sample Output 0
0,3
Sample Input 1
Date – 12th Sept, 2024
3
8 96 15
Sample Output 1
-1,-1
int n = in.nextInt();
nums[i] = in.nextInt();
arr[0] = i;
arr[1] = j;
4. Power Digits
Preeti is playing a game with her brother Kabir, where she wins if her number's digits are so well-
behaved that when each is raised to its position power, they add up perfectly to the original number.
If not, her brother wins and gets to brag about his superior math skills!
Input Format
A positive integer n.
Constraints
1 ≤ n ≤ 10^6
Output Format
Sample Input 0
135
Sample Output 0
Preeti
Sample Input 1
Date – 12th Sept, 2024
175
Sample Output 1
Preeti
import java.util.Scanner;
int sum = 0;
int rem;
int n = num;
int len = 0;
while (n != 0) {
len++;
n = n / 10;
n = num;
len--;
if (sum == n) {
System.out.println("Preeti");
} else {
System.out.println("Kabir");
scanner.close();