7 682
Подписчики
-324 часа
-287 дней
+3030 день
Архив постов
DeShaw OA help available ✅
100% CLEARANCE FOR YOUR EXAM ✅
Contact: @MLCODER2
VIRTUSA SLOTS ARE AVAILABLE ✅
💯 clearance for your exam
Contact: @MLCODER2
import java.util.*;
public class Main{
public static Node findchain(Node chain1, Node chain2) {
int len1 = getLength(chain1);
int len2 = getLength(chain2);
Node ptr1 = chain1;
Node ptr2 = chain2;
if (len1 > len2) {
int diff = len1 - len2;
while (diff-- > 0) ptr1 = ptr1.next;
} else {
int diff = len2 - len1;
while (diff-- > 0) ptr2 = ptr2.next;
}
while (ptr1 != null && ptr2 != null && ptr1 != ptr2) {
ptr1 = ptr1.next;
ptr2 = ptr2.next;
}
Node mergePoint = ptr1;
int beforeMerge1 = getDistance(chain1, mergePoint);
int beforeMerge2 = getDistance(chain2, mergePoint);
Node result = null;
if (beforeMerge1 < beforeMerge2 || (beforeMerge1 == beforeMerge2)) {
result = cloneUntil(chain1, mergePoint);
appendTail(result, mergePoint);
} else {
result = cloneUntil(chain2, mergePoint);
appendTail(result, mergePoint);
}
return result;
}
private static int getLength(Node head) {
int count = 0;
while (head != null) {
head = head.next;
count++;
}
return count;
}
private static int getDistance(Node head, Node stop) {
int count = 0;
while (head != stop) {
head = head.next;
count++;
}
return count;
}
private static Node cloneUntil(Node head, Node stop) {
if (head == stop) return null;
Node newHead = new Node(head.value);
Node current = newHead;
head = head.next;
while (head != stop) {
current.next = new Node(head.value);
current = current.next;
head = head.next;
}
return newHead;
}
private static void appendTail(Node head, Node tailStart) {
if (head == null) return;
while (head.next != null) {
head = head.next;
}
head.next = tailStart;
}
}
JAVA SE8 certification exam ✅✅
56 Java mcqs✅✅
Contact : @MLCODER2
+2
UBS exam done successfully ✅✅
100% clearance for any exam ✅
Contact : @MLCODER2
def getMaximumSum(matrix, k):
global idx
import heapq
from collections import deque
n = len(matrix)
rows = [deque(row) for row in matrix]
heap = []
for i in range(n):
if rows[i]:
heapq.heappush(heap, (-rows[i][0], i, True))
heapq.heappush(heap, (-rows[i][-1], i, False))
ans= 0
for _ in range(k):
while heap:
val, idx, is_left = heapq.heappop(heap)
if rows[idx]:
if is_left and rows[idx][0] == -val:
ans += rows[idx].popleft()
break
elif not is_left and rows[idx][-1] == -val:
ans += rows[idx].pop()
break
if rows[idx]:
heapq.heappush(heap, (-rows[idx][0], idx, True))
heapq.heappush(heap, (-rows[idx][-1], idx, False))
return ans
getMaximumSum✅✅
CISCO✅
Уже доступно! Исследование Telegram 2025 — ключевые инсайты года 
