7 688
Suscriptores
-624 horas
-177 días
+3530 días
Archivo de publicaciones
IBM CLEARED & GOT COMMUNICATION MAIL✅
Contact : @MLCODER2
import java.util.*;
class SolutionClass {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int K = sc.nextInt();
String s = sc.next();
Set<Integer>set= new HashSet<>();
for (int i = 0; i < K; i++) set.add(sc.nextInt());
StringBuilder sb = new StringBuilder();
int i = 0;
while (i < n) {
int j = i + 1;
while (j < n && s.charAt(j) == s.charAt(i)) j++;
int len = j - i;
if (!set.contains(len)) {
sb.append(s, i, j);
}
i = j;
}
System.out.println(sb.length() == 0 ? "ERROR" : sb.toString());
}
}
//consecutive characters✅
CAPGEMINI✅
class SolutionClass {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s = sc.nextLine().trim();
int k= 0;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c >= '0' && c <= '9') k += (c - '0');
}
System.out.println(s + solve(k));
}
private static int solve(int n) {
if (n <= 1) return n;
int a = 0, b = 1;
while (b < n) {
int c = a + b;
a = b;
b = c;
}
return b;
}
}
//kingdom communication✅
CAPGEMINI✅
IBM CLEARED & GOT COMMUNICATION MAIL ✅✅
Your exam clearance is💯
Contact : @MLCODER2
def uniqueArrangements( input1, input2, input3):
n = input1
k = input2
arr = input3
unique_patterns = set()
for i in range(n - k + 1):
new_pattern = tuple(arr[:i] + arr[i + k:])
unique_patterns.add(new_pattern)
return len(unique_patterns)
//The Robot Transmission Filter✅
def find_equal_biomass_cut(input1, input2, input3):
n = input1
biomass = input2
edges = input3
graph = [[] for _ in range(n)]
for u, v in edges:
graph[u].append(v)
graph[v].append(u)
total = sum(biomass)
if total % 2 != 0:
return [-1, -1]
target = total // 2
valid_cuts = []
visited = [False] * n
def dfs(node):
visited[node] = True
subtotal = biomass[node]
for nei in graph[node]:
if not visited[nei]:
sub = dfs(nei)
subtotal += sub
if sub == target:
valid_cuts.append(sorted([node, nei]))
return subtotal
dfs(0)
if not valid_cuts:
return [-1, -1]
valid_cuts.sort()
return valid_cuts[0]
//Equal Biomass Partition✅✅
def longest_decay_path(cls, input1, input2, input3, input4, input5):
N, M = input1, input2
grid = input3
start_x, start_y = input4, input5
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
dp = [[-1] * M for _ in range(N)]
def dfs(x, y):
if dp[x][y] != -1:
return dp[x][y]
max_len = 1
for dx, dy in directions:
nx, ny = x + dx, y + dy
if 0 <= nx < N and 0 <= ny < M and grid[nx][ny] < grid[x][y]:
max_len = max(max_len, 1 + dfs(nx, ny))
dp[x][y] = max_len
return dp[x][y]
return dfs(start_x, start_y)
//Decay Trail Optimization✅
VIRTUSA✅✅
def transform_to_smallest_prime(cls, input1, input2):
from collections import deque
N, K = str(input1), input2
n = len(N)
def is_prime(x):
if x < 2:
return False
if x % 2 == 0 and x != 2:
return False
d = 3
while d * d <= x:
if x % d == 0:
return False
d += 2
return True
q = deque([(N, 0)])
seen = {N: 0}
best_prime = None
while q:
cur, steps = q.popleft()
if steps <= K:
val = int(cur)
if cur[0] != '0' and is_prime(val):
if best_prime is None or val < best_prime:
best_prime = val
if steps < K:
for i in range(n):
d = int(cur[i])
for nd in [d - 1, d + 1]:
if 0 <= nd <= 9:
nxt = cur[:i] + str(nd) + cur[i+1:]
if nxt not in seen or seen[nxt] > steps + 1:
seen[nxt] = steps + 1
q.append((nxt, steps + 1))
return best_prime if best_prime is not None else -1
//prime transformation✅✅
VIRTUSA✅
def maximizeQuality(cls, input1, input2, input3):
n = input1
R = input2
P = input3
X = []
for b in range(32):
mask = 1 << b
contrib = 0
for val in P:
contrib += (val & mask)
X.append((contrib, b))
X.sort(key=lambda x: (-x[0], x[1]))
chosen = sorted([b for _, b in X[:R]])
result = 0
for b in chosen:
result |= (1 << b)
return result
//MAXIMIZE THE QUALITY✅
VIRTUSA✅
from collections import deque
def minMovesToHospital(cls, input1, input2, input3):
N = input1
E = input2
K = input3 - 1
if E[K] == 0:
return 0
visited = [False] * N
q = deque([(K, 0)])
visited[K] = True
while q:
idx, moves = q.popleft()
for nxt in [idx + E[idx], idx - E[idx]]:
if 0 <= nxt < N and not visited[nxt]:
if E[nxt] == 0:
return moves + 1
visited[nxt] = True
q.append((nxt, moves + 1))
return -1
//MINIMUM MOVES✅
VIRTUSA✅
def maxSumOfNonAdjacentNodes(cls, input1, input2):
a = input2
n = len(a)
if n == 0:
return 0
eff = [0]*n
for i in range(n):
penalty = a[i-1] if i > 0 and a[i-1] < 0 else 0
eff[i] = a[i] + penalty
def nz(x):
return x if x > 0 else 0
if n == 1:
return nz(eff[0])
if n == 2:
return max(nz(eff[0]), nz(eff[1]))
prev2 = nz(eff[0])
prev1 = max(prev2, nz(eff[1]))
for i in range(2, n):
take = prev2 + nz(eff[i])
skip = prev1
cur = take if take > skip else skip
prev2, prev1 = prev1, cur
return prev1
//MAX REWARD POINTS✅
VIRTUSA✅
def legoString(input1, input2, input3):
wall = input1
n = input2
blocks = input3
if not wall or not blocks:
return [-1]
word_len = len(blocks[0])
if len(wall) < word_len:
return [-1]
from collections import Counter
block_count = Counter(blocks)
result = []
for i in range(len(wall) - word_len + 1):
for used in range(2, n+1):
length = used * word_len
if i + length > len(wall):
break
substring = wall[i:i+length]
words = [substring[j:j+word_len] for j in range(0, length, word_len)]
count_words = Counter(words)
if all(count_words[w] <= block_count[w] for w in count_words) and sum(count_words.values()) == used:
result.append(i)
return sorted(set(result)) if result else [-1]
//Legato strings✅✅
VIRTUSA✅
¡Ya disponible! Investigación de Telegram 2025 — los principales insights del año 
