Java Hyd Team
746 subscribers
986 photos
39 videos
670 files
690 links
https://teamhydteam.my.canva.site/

Can visit us on our website ๐Ÿ˜Š
Still working on it ๐Ÿ˜Š
Download Telegram
Forwarded from Aman Raj
Bob received an assignment from his school: he has two numbers AA and BB, and he has to find the sum of these two numbers.
Alice, being a good friend of Bob, told him that the answer to this question is CC.
Bob doesn't completely trust Alice and asked you to tell him if the answer given by Alice is correct or not.
If the answer is correct print "YES", otherwise print "NO" (without quotes).

Input Format
The first line of input will contain a single integer TT, denoting the number of test cases.
The first and only line of each test case consists of three space-separated integers A, B,A,B, and CC.
Output Format
For each test case, output on a new line the answer: YES if Alice gave the right answer, and NO otherwise.

Each character of the output may be printed in either uppercase or lowercase, i.e, the outputs Yes, YES, yEs and yes will be treated as equivalent.

Constraints
1 \leq T \leq 1001โ‰คTโ‰ค100
0 \leq A , B , C \leq 1000โ‰คA,B,Cโ‰ค100
Forwarded from Aman Raj
Alice thinks Bob has very weak math skills.
Alice gave Bob three numbers A, B,A,B, and CC and challenged him to find any positive integer KK strictly less than 100100 such that none of the three numbers are divisible by KK.

Help Bob find one such integer KK.

Under the given constraints, a valid KK will always exist.

Input Format
The first line of input will contain a single integer TT, denoting the number of test cases.
The first and only line of each test case contains three space-separated integers A, B,A,B, and CC.
Output Format
For each test case, output on a new line any positive integer KK less than 100100 that does not divide any of A, B,A,B, or CC.

Constraints
1 \leq T \leq 10001โ‰คTโ‰ค1000
2 \leq A , B , C \leq 1002โ‰คA,B,Cโ‰ค100
Forwarded from Aman Raj
Suppose you have a binary array BB of length NN.
A sequence x_1, x_2, \ldots, x_kx
1
โ€‹
,x
2
โ€‹
,โ€ฆ,x
k
โ€‹
is called good with respect to BB if it satisfies the following conditions:

1 \leq x_1 \lt x_2 \lt \ldots \lt x_k \leq N+11โ‰คx
1
โ€‹
<x
2
โ€‹
<โ€ฆ<x
k
โ€‹
โ‰คN+1
For every pair (i, j)(i,j) such that 1 \leq i \lt j \leq k1โ‰คi<jโ‰คk, the subarray B[x_i: x_j-1]B[x
i
โ€‹
:x
j
โ€‹
โˆ’1] contains (j-i)(jโˆ’i) more ones than zeros.
That is, if B[x_i : x_j-1]B[x
i
โ€‹
:x
j
โ€‹
โˆ’1] contains c_1c
1
โ€‹
ones and c_0c
0
โ€‹
zeros, then c_1 - c_0 = j-ic
1
โ€‹
โˆ’c
0
โ€‹
=jโˆ’i must hold.
Here, B[L: R]B[L:R] denotes the subarray consisting of elements [B_L, B_{L+1}, B_{L+2}, \ldots, B_R][B
L
โ€‹
,B
L+1
โ€‹
,B
L+2
โ€‹
,โ€ฆ,B
R
โ€‹
].
Note that in particular, a sequence of size 11 is always good.

For example, suppose B = [0,1,1,0,1,1]B=[0,1,1,0,1,1]. Then,

The sequence [1,4,7][1,4,7] is a good sequence. The subarrays that need to be checked are B[1:3], B[1:6]B[1:3],B[1:6] and B[4:6]B[4:6], which all satisfy the condition.
The sequence [1, 5][1,5] is not good, because B[1:4] = [0, 1, 1, 0]B[1:4]=[0,1,1,0] contains an equal number of zeros and ones (when it should contain one extra 11).
Alice gave Bob a binary array AA of size NN and asked him to find the longest sequence that is good with respect to AA. Help Bob find one such sequence.
If multiple possible longest sequences exist, you may print any of them.

Input Format
The first line of input will contain a single integer TT, denoting the number of test cases.
Each test case consists of two lines of input.
The first line of each test case contains a single integer NN โ€” the size of the binary array.
The second line contains NN space-separated numbers โ€” A_1 , A_2 , \ldots , A_NA
1
โ€‹
,A
2
โ€‹
,โ€ฆ,A
N
โ€‹
.
Output Format
Each test case requires two lines of output:

First, print on a new line a single integer KK โ€” the maximum length of a sequence that is good with respect to AA
On the next line, print KK space-separated integers in increasing order, denoting the indices of one such sequence.
If there are multiple possible good sequences with maximum size, output any of them.

Constraints
1 \leq T \leq 10^51โ‰คTโ‰ค10
5

1 \leq N \leq 10^51โ‰คNโ‰ค10
5

0 \leq A_i \leq 10โ‰คA
i
โ€‹
โ‰ค1
The sum of NN over all test cases won't exceed 10^610
6
.
Forwarded from Aman Raj
Reyaan has given you the following problem to solve:

You are given an integer KK in base BB, represented by an array AA of length NN such that

0 \leq A_i \lt B0โ‰คA
i
โ€‹
<B for every 1 \leq i \leq N1โ‰คiโ‰คN
\sum_{i=1}^N A_i \cdot B^{N-i} = Kโˆ‘
i=1
N
โ€‹
A
i
โ€‹
โ‹…B
Nโˆ’i
=K
Note that N \leq BNโ‰คB in this problem.

Find the smallest non-negative integer XX such that X+KX+K contains every digit from 00 to B-1Bโˆ’1 in its base-BB representation.

XX can be very large, so print the answer modulo 10^9 + 710
9
+7.

Note: Leading zeros are not counted as part of the number, so for example 12 = 01212=012 has only two distinct digits: 11 and 22. However, 102102 does have three distinct digits.

Input Format
The first line of input will contain a single integer TT, denoting the number of test cases.
Each test case consists of two lines of input.
The first line of each test case contains two space-separated integers NN and BB โ€” the size of the array AA and the base.
The second line of each test case contains NN space-separated integers A_1, A_2, \ldots, A_NA
1
โ€‹
,A
2
โ€‹
,โ€ฆ,A
N
โ€‹
.
Output Format
For each test case, output on a new line the value of XX, modulo 10^9 + 710
9
+7.

Constraints
1 \leq T \leq 10^41โ‰คTโ‰ค10
4

1 \leq N \leq 10^61โ‰คNโ‰ค10
6

2 \leq B \leq 10^62โ‰คBโ‰ค10
6

N \leq BNโ‰คB
0 \leq A_i \lt B0โ‰คA
i
โ€‹
<B
A_1 \gt 0A
1
โ€‹
>0, i.e, the given number doesn't contain leading zeros.
The sum of BB across all test cases won't exceed 10^610
6
.
Forwarded from Aman Raj
There is a tree with NN vertices, rooted at vertex 11. Vertex ii has the value A_iA
i
โ€‹
written on it.

Alice walks along this tree, starting at the root.
When she is at vertex uu:

If uu has no children, she stops.
Otherwise, suppose uu has cc children. She picks one of them at random (each one has a \frac{1}{c}
c
1
โ€‹
probability of being picked), and then moves to it.
Alice also has a score, defined as follows:

Let the vertices she visited be u_1, u_2, \ldots, u_ku
1
โ€‹
,u
2
โ€‹
,โ€ฆ,u
k
โ€‹

Then, she will forget exactly one of these kk vertices; and her score will be the bitwise xor of the remaining ones.
That is, if she chooses to forget vertex u_iu
i
โ€‹
, then her score is A_{u_1} \oplus A_{u_2} \oplus \ldots \oplus A_{u_{i-1}} \oplus A_{u_{i+1}} \oplus \ldots \oplus A_{u_{k}}A
u
1
โ€‹

โ€‹
โŠ•A
u
2
โ€‹

โ€‹
โŠ•โ€ฆโŠ•A
u
iโˆ’1
โ€‹

โ€‹
โŠ•A
u
i+1
โ€‹

โ€‹
โŠ•โ€ฆโŠ•A
u
k
โ€‹

โ€‹
. Here, \oplusโŠ• denotes the bitwise xor operation.
Alice wants to maximize her score, and will always choose to forget a vertex optimally to achieve this.

What is Alice's expected final score?

Find the expected value modulo 10^9 + 710
9
+7.
That is, the expected value can be written as \frac{P}{Q}
Q
P
โ€‹
for two integers P, QP,Q such that \gcd(Q, 10^9 + 7) = 1gcd(Q,10
9
+7)=1; print the value of P\cdot Q^{-1} \pmod{10^9 + 7}Pโ‹…Q
โˆ’1
(mod10
9
+7).

Input Format
The first line of input will contain a single integer TT, denoting the number of test cases.
Each test case consists of multiple lines of input.
The first line of each test case contains a single integer NN โ€” the number of vertices of the tree.
The second line of each test case contains NN space-separated integers A_1, A_2, \ldots, A_NA
1
โ€‹
,A
2
โ€‹
,โ€ฆ,A
N
โ€‹
.
The next N-1Nโˆ’1 lines describe the edges. The i^{th}i
th
of these lines contains two space-separated integers u_iu
i
โ€‹
and v_iv
i
โ€‹
, denoting an edge between u_iu
i
โ€‹
and v_iv
i
โ€‹
.
Output Format
For each test case, output on a new line Alice's expected final score.

Constraints
1 \leq T \leq 10^41โ‰คTโ‰ค10
4

1 \leq N \leq 5\cdot 10^51โ‰คNโ‰ค5โ‹…10
5

1 \leq A_i \leq 10^91โ‰คA
i
โ€‹
โ‰ค10
9

The sum of NN over all test cases won't exceed 5\cdot 10^55โ‹…10
5
solve it
copy ques in notepad then do else you may get issue in understanding question
How many of you wanna learn JavaScript validation this Sunday will do one masterclass
Anonymous Poll
100%
Yes
0%
No
Whoever wants just message me @stockkida with your email ID ๐Ÿ™‚ will add details to your calendar ๐Ÿ—“๏ธ
The way you guy's are voting looks like you guy's know everything n no need to consume more data
Java Hyd Team pinned ยซThe way you guy's are voting looks like you guy's know everything n no need to consume more dataยป
Java Hyd Team
WHICH SUBJECT YOU WANT TO LEARN WITH US WITH A IMPLEMENTED PROJECT
Will cover core Java along with javascript validations this Sunday ๐Ÿ˜Š
public class PalindromeNumber {
public static void main(String[] args) {
int x = -121;
if(isPalindrome(x)){
System.out.println(x + " is a Palindrome number");
}
else{
System.out.println(x + " is not a Palindrome number");
}
}

public static boolean isPalindrome(int x) {
if(x < 0 || (x % 10 == 0 && x != 0)) {
return false;
}

int revertedNumber = 0;
while(x > revertedNumber) {
revertedNumber = revertedNumber * 10 + x % 10;
x /= 10;
}

// When the length is an odd number, we can get rid of the middle digit by revertedNumber/10
// For example when the input is 12321, at the end of the while loop we get x = 12, revertedNumber = 123,
// since the middle digit doesn't matter in palidrome(it will always equal to itself), we can simply get rid of it.
return x == revertedNumber || x == revertedNumber/10;
}
}
Given a valid (IPv4) IP address, return a defanged version of that IP address.

A defanged IP address replaces every period "." with "[.]".



Example 1:

Input: address = "1.1.1.1"
Output: "1[.]1[.]1[.]1"
Example 2:

Input: address = "255.100.50.0"
Output: "255[.]100[.]50[.]0"


Constraints:

The given address is a valid IPv4 address.
There is a programming language with only four operations and one variable X:

++X and X++ increments the value of the variable X by 1.
--X and X-- decrements the value of the variable X by 1.
Initially, the value of X is 0.

Given an array of strings operations containing a list of operations, return the final value of X after performing all the operations.



Example 1:

Input: operations = ["--X","X++","X++"]
Output: 1
Explanation: The operations are performed as follows:
Initially, X = 0.
--X: X is decremented by 1, X = 0 - 1 = -1.
X++: X is incremented by 1, X = -1 + 1 = 0.
X++: X is incremented by 1, X = 0 + 1 = 1.
Example 2:

Input: operations = ["++X","++X","X++"]
Output: 3
Explanation: The operations are performed as follows:
Initially, X = 0.
++X: X is incremented by 1, X = 0 + 1 = 1.
++X: X is incremented by 1, X = 1 + 1 = 2.
X++: X is incremented by 1, X = 2 + 1 = 3.
Example 3:

Input: operations = ["X++","++X","--X","X--"]
Output: 0
Explanation: The operations are performed as follows:
Initially, X = 0.
X++: X is incremented by 1, X = 0 + 1 = 1.
++X: X is incremented by 1, X = 1 + 1 = 2.
--X: X is decremented by 1, X = 2 - 1 = 1.
X--: X is decremented by 1, X = 1 - 1 = 0.


Constraints:

1 <= operations.length <= 100
operations[i] will be either "++X", "X++", "--X", or "X--".
1480. Running Sum of 1d Array
Easy
5.7K
281
Companies
Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]โ€ฆnums[i]).

Return the running sum of nums.



Example 1:

Input: nums = [1,2,3,4]
Output: [1,3,6,10]
Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].
Example 2:

Input: nums = [1,1,1,1,1]
Output: [1,2,3,4,5]
Explanation: Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].
Example 3:

Input: nums = [3,1,2,10,1]
Output: [3,4,6,16,17]


Constraints:

1 <= nums.length <= 1000
-10^6 <= nums[i] <= 10^6