def f(N, L, R, A):
M = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1 # There's one way to partition an empty array
for i in range(1, N + 1):
xv = 0
for j in range(i, 0, -1):
xv ^= A[j - 1]
if L <= xv <= R:
dp[i] = (dp[i] + dp[j - 1]) % M
return dp[N]
// divide the array
@allcoding1_official
M = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1 # There's one way to partition an empty array
for i in range(1, N + 1):
xv = 0
for j in range(i, 0, -1):
xv ^= A[j - 1]
if L <= xv <= R:
dp[i] = (dp[i] + dp[j - 1]) % M
return dp[N]
// divide the array
@allcoding1_official
π1
MOD = 10**9 + 7
def f(X, P, L, R):
s = [(x, x + p) for x, p in zip(X, P)]
s.sort()
c = 0
i = 0
e = L
f = L
while e <= R:
while i < len(s) and s[i][0] <= e:
f = max(f, s[i][1])
i += 1
if f == e:
return -1
c += 1
e = f + 1
return c
def g(N, M, X, P, Q, Qs):
t = 0
for L, R in Qs:
r = f(X, P, L, R)
t = (t + r) % MOD
return t
// Lighting lamp
@allcoding1_official
def f(X, P, L, R):
s = [(x, x + p) for x, p in zip(X, P)]
s.sort()
c = 0
i = 0
e = L
f = L
while e <= R:
while i < len(s) and s[i][0] <= e:
f = max(f, s[i][1])
i += 1
if f == e:
return -1
c += 1
e = f + 1
return c
def g(N, M, X, P, Q, Qs):
t = 0
for L, R in Qs:
r = f(X, P, L, R)
t = (t + r) % MOD
return t
// Lighting lamp
@allcoding1_official
π1
def main():
import sys
input = sys.stdin.read
data = input().split('\n')
S = data[0].strip()
N = int(data[1].strip())
W = []
for i in range(N):
W.append(data[2 + i].strip())
freqS = get_frequency(S)
count = 0
for w in W:
if is_valid_anagram_subsequence(freqS, w):
count += 1
print(count)
def get_frequency(S):
freq = [0] * 26
for c in S:
freq[ord(c) - ord('a')] += 1
return freq
def is_valid_anagram_subsequence(freqS, w):
freqW = [0] * 26
for c in w:
freqW[ord(c) - ord('a')] += 1
for i in range(26):
if freqW[i] > freqS[i]:
return False
return True
if name == "main":
main()
// MInimal subarray length
@allcoding1_official
import sys
input = sys.stdin.read
data = input().split('\n')
S = data[0].strip()
N = int(data[1].strip())
W = []
for i in range(N):
W.append(data[2 + i].strip())
freqS = get_frequency(S)
count = 0
for w in W:
if is_valid_anagram_subsequence(freqS, w):
count += 1
print(count)
def get_frequency(S):
freq = [0] * 26
for c in S:
freq[ord(c) - ord('a')] += 1
return freq
def is_valid_anagram_subsequence(freqS, w):
freqW = [0] * 26
for c in w:
freqW[ord(c) - ord('a')] += 1
for i in range(26):
if freqW[i] > freqS[i]:
return False
return True
if name == "main":
main()
// MInimal subarray length
@allcoding1_official
def GetAnswer(N, A, B, P):
dp = [0] * (N + 1)
max_d = 0
for i in range(N - 1, -1, -1):
max_p = P[i]
min_p = P[i]
for j in range(1, B + 1):
if i + j <= N:
max_p = max(max_p, P[i + j - 1])
min_p = min(min_p, P[i + j - 1])
max_d = max(max_d, max_p - min_p)
if i + 1 == N:
dp[i] = max(dp[i], max_d)
else:
dp[i] = max(dp[i], max_d, dp[i + 1])
return dp[0]
import sys
input = sys.stdin.read
data = input().split()
N = int(data[0])
A = int(data[1])
B = int(data[2])
P = list(map(int, data[3:]))
result = GetAnswer(N, A, B, P)
print(result)
// XOR formaating code
@allcoding1_official
dp = [0] * (N + 1)
max_d = 0
for i in range(N - 1, -1, -1):
max_p = P[i]
min_p = P[i]
for j in range(1, B + 1):
if i + j <= N:
max_p = max(max_p, P[i + j - 1])
min_p = min(min_p, P[i + j - 1])
max_d = max(max_d, max_p - min_p)
if i + 1 == N:
dp[i] = max(dp[i], max_d)
else:
dp[i] = max(dp[i], max_d, dp[i + 1])
return dp[0]
import sys
input = sys.stdin.read
data = input().split()
N = int(data[0])
A = int(data[1])
B = int(data[2])
P = list(map(int, data[3:]))
result = GetAnswer(N, A, B, P)
print(result)
// XOR formaating code
@allcoding1_official
π1
public static int solve(int N, int[] A) {
int t = 0;
for (int num : A) {
t += num;
}
int x = 0;
int y = 0;
for (int i = 0; i < N; i++) {
int res = t - x - A[i];
if (x == res) {
y++;
}
x += A[i];
}
return y;
}
//Equilibrium Point
@allcoding1_official
int t = 0;
for (int num : A) {
t += num;
}
int x = 0;
int y = 0;
for (int i = 0; i < N; i++) {
int res = t - x - A[i];
if (x == res) {
y++;
}
x += A[i];
}
return y;
}
//Equilibrium Point
@allcoding1_official
def f(S):
n = len(S)
lf, rf = {}, {}
ls, rs = set(), set()
# Initialize the rf map and rs with the entire string S
for c in S:
rf[c] = rf.get(c, 0) + 1
rs.add(c)
mx = 0
# Traverse the string and adjust the ls and rs sets and maps
for i in range(n - 1):
c = S[i]
lf[c] = lf.get(c, 0) + 1
rf[c] -= 1
if rf[c] == 0:
rs.remove(c)
ls.add(c)
cs = len(ls) + len(rs)
mx = max(mx, cs)
return n - mx
// spilit screen
@allcoding1_official
n = len(S)
lf, rf = {}, {}
ls, rs = set(), set()
# Initialize the rf map and rs with the entire string S
for c in S:
rf[c] = rf.get(c, 0) + 1
rs.add(c)
mx = 0
# Traverse the string and adjust the ls and rs sets and maps
for i in range(n - 1):
c = S[i]
lf[c] = lf.get(c, 0) + 1
rf[c] -= 1
if rf[c] == 0:
rs.remove(c)
ls.add(c)
cs = len(ls) + len(rs)
mx = max(mx, cs)
return n - mx
// spilit screen
@allcoding1_official
π1
All codes are available
To easily find out ur codes
Once check it ππ
https://www.instagram.com/allcoding1_official?igsh=ZHJpNXdpeWh1d2No
To easily find out ur codes
Once check it ππ
https://www.instagram.com/allcoding1_official?igsh=ZHJpNXdpeWh1d2No
π1
π―Wells Fargo Hiring Fresher For Analytics Associate
Location: Hyderabad
Qualification: Bachelors / Masterβs degree
Work Experience : Fresher - 1 Year
Salary : 10 - 11 LPA
Apply Now:- https://wd1.myworkdaysite.com/recruiting/wf/WellsFargoJobs/job/Hyderabad-India/Analytics-Associate_R-381215
Telegram:- @allcoding1_official
Location: Hyderabad
Qualification: Bachelors / Masterβs degree
Work Experience : Fresher - 1 Year
Salary : 10 - 11 LPA
Apply Now:- https://wd1.myworkdaysite.com/recruiting/wf/WellsFargoJobs/job/Hyderabad-India/Analytics-Associate_R-381215
Telegram:- @allcoding1_official
π3
Mitsogo is hiring Fresher
Apply link π
https://boards.greenhouse.io/mitsogoinc/jobs/4045384008?gh_src=eacea7cc8us
Apply link π
https://boards.greenhouse.io/mitsogoinc/jobs/4045384008?gh_src=eacea7cc8us
π3
Adobe is hiring for SDE l role |
0 - 2 years experience | Noida location | CTC : 12 - 20 LPA ( expected )
https://careers.adobe.com/us/en/job/ADOBUSR146901EXTERNALENUS/Software-Development-Engineer?utm_medium=phenom-feeds&source=LinkedIn&utm_source=linkedin
0 - 2 years experience | Noida location | CTC : 12 - 20 LPA ( expected )
https://careers.adobe.com/us/en/job/ADOBUSR146901EXTERNALENUS/Software-Development-Engineer?utm_medium=phenom-feeds&source=LinkedIn&utm_source=linkedin
π3
miniOrange is hiring for Software Engineer Java
2024/2023/2022 batches eligible
Location : Pune
Last date to apply : 6 PM, 10 July 2024
CTC : 6 - 8 LPA ( expected )
Apply Now :-
https://www.miniorange.com/career/hiring-drive
2024/2023/2022 batches eligible
Location : Pune
Last date to apply : 6 PM, 10 July 2024
CTC : 6 - 8 LPA ( expected )
Apply Now :-
https://www.miniorange.com/career/hiring-drive
π2β€1
Interview Kickstart is hiring for Frontend Engineer I and II | 1 - 4 years experience | Remote |
Apply Now:-
https://interviewkickstart.keka.com/careers/jobdetails/45540
Apply Now:-
https://interviewkickstart.keka.com/careers/jobdetails/45540
π2
class Result {
public static void goodSequence(BufferedReader bufferedReader) throws IOException {
StringTokenizer st = new StringTokenizer(bufferedReader.readLine());
int T = Integer.parseInt(st.nextToken());
for (int t = 0; t < T; t++) {
st = new StringTokenizer(bufferedReader.readLine(), ",");
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
st = new StringTokenizer(bufferedReader.readLine(), ",");
int[] sequence = new int[N];
for (int i = 0; i < N; i++) {
sequence[i] = Integer.parseInt(st.nextToken());
}
String result = solveTestCase(N, M, sequence);
System.out.println(result);
}
}
private static String solveTestCase(int N, int M, int[] sequence) {
int countDivisible = 0;
for (int x : sequence) {
if (x % M == 0) {
countDivisible++;
}
}
if (countDivisible == 0) {
return "0/1";
}
long totalSubsequences = (1L << N) - 1;
long goodSubsequences = (1L << countDivisible) - 1;
long P = goodSubsequences;
long Q = totalSubsequences;
long commonDivisor = gcd(P, Q);
P /= commonDivisor;
Q /= commonDivisor;
return P + "/" + Q;
}
private static long gcd(long a, long b) {
while (b != 0) {
long temp = b;
b = a % b;
a = temp;
}
return a;
}
}
public static void goodSequence(BufferedReader bufferedReader) throws IOException {
StringTokenizer st = new StringTokenizer(bufferedReader.readLine());
int T = Integer.parseInt(st.nextToken());
for (int t = 0; t < T; t++) {
st = new StringTokenizer(bufferedReader.readLine(), ",");
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
st = new StringTokenizer(bufferedReader.readLine(), ",");
int[] sequence = new int[N];
for (int i = 0; i < N; i++) {
sequence[i] = Integer.parseInt(st.nextToken());
}
String result = solveTestCase(N, M, sequence);
System.out.println(result);
}
}
private static String solveTestCase(int N, int M, int[] sequence) {
int countDivisible = 0;
for (int x : sequence) {
if (x % M == 0) {
countDivisible++;
}
}
if (countDivisible == 0) {
return "0/1";
}
long totalSubsequences = (1L << N) - 1;
long goodSubsequences = (1L << countDivisible) - 1;
long P = goodSubsequences;
long Q = totalSubsequences;
long commonDivisor = gcd(P, Q);
P /= commonDivisor;
Q /= commonDivisor;
return P + "/" + Q;
}
private static long gcd(long a, long b) {
while (b != 0) {
long temp = b;
b = a % b;
a = temp;
}
return a;
}
}
π4β€1