Фотография
нажмите — покажем
нажмите — покажем
Фотография
нажмите — покажем
нажмите — покажем
Deloitte | COGNIZANT | IBM | CAPGEMINI
def process_usage_logs(usage_records, reference_day, region_details, profiles, region_stats):
for record in usage_records:
usage_id, region_id, usage_day, cpu_usage, memory_usage = record
usage_day = int(usage_day)
cpu_usage = int(cpu_usage)
memory_usage = int(memory_usage)
if region_id not in region_details:
continue
if not (1 <= usage_day <= reference_day):
continue
if cpu_usage < 0 or memory_usage < 0:
continue
region_type = region_details[region_id][1]
max_cpu, max_mem = profiles[region_type]
stats = region_stats[region_id]
stats["valid_usage_count"] += 1
stats["cpu_sum"] += cpu_usage
stats["memory_sum"] += memory_usage
if cpu_usage > max_cpu:
stats["cpu_breach_count"] += 1
if memory_usage > max_mem:
stats["memory_breach_count"] += 1
def process_deployments(deployment_records, reference_day, region_details, region_stats):
for record in deployment_records:
deployment_id, region_id, deployment_day, deployment_status = record
deployment_day = int(deployment_day)
if region_id not in region_details:
continue
if deployment_status not in VALID_DEPLOYMENT_STATUSES:
continue
if not (1 <= deployment_day <= reference_day):
continue
if deployment_status == "ACTIVE":
region_stats[region_id]["active_deployment_count"] += 1
def process_incident_reports(incident_records, reference_day, region_details, region_stats):
for record in incident_records:
incident_id, region_id, incident_day, severity = record
incident_day = int(incident_day)
if region_id not in region_details:
continue
if severity not in VALID_INCIDENT_SEVERITIES:
continue
if not (1 <= incident_day
566 · if score >= 10:
risk_level = "HIGH"
elif score >= 6:
risk_level = "MEDIUM"
else:
risk_level = "LOW"
if risk_level in ("HIGH", "MEDIUM"):
output_regions.append({
"name": region_name,
"risk_level": risk_level,
"score": score,
"active_deployments": active_deployments,
"input_index": input_index
})
if not output_regions:
print("NA")
return
output_regions.sort(key=lambda x: (
0 if x["risk_level"] == "HIGH" else 1,
-x["score"],
x["active_deployments"],
x["input_index"]
))
formatted_strings = [
f"{r['name']}-{r['risk_level']}-{r['score']}-{r['active_deployments']}"
for r in output_regions
]
print("#".join(formatted_strings))
FLIPART✅
DATAFRAME✅
466 · WITH connection_usage AS (
SELECT
connection_ref,
COALESCE(SUM(internet_mb), 0) / 1024.0 AS connection_internet_gb
FROM daily_service_consumption
WHERE consumption_date >= '2024-02-01' AND consumption_date < '2024-03-01'
GROUP BY connection_ref
),
bill_details AS (
SELECT
b.bill_ref,
b.connection_ref,
b.payable_amount,
LEAST(b.payable_amount, COALESCE(SUM(CASE WHEN t.transaction_state = 'SUCCESS' THEN t.transaction_amount ELSE 0 END), 0)) AS bill_collected_amount
FROM monthly_service_bills b
LEFT JOIN bill_transactions t ON b.bill_ref = t.bill_ref
WHERE b.cycle_month = '2024-02-01' AND b.bill_state != 'CANCELLED'
GROUP BY b.bill_ref, b.connection_ref, b.payable_amount
),
connection_bills AS (
SELECT
connection_ref,
SUM(payable_amount) AS total_conn_bill_amount,
SUM(bill_collected_amount) AS total_conn_collected_amount
FROM bill_details
GROUP BY connection_ref
)
SELECT
p.package_ref,
p.package_label,
COUNT(DISTINCT mc.connection_ref) AS active_connection_count,
ROUND(SUM(COALESCE(cu.connection_internet_gb, 0)), 2) AS total_internet_gb,
ROUND(SUM(cb.total_conn_bill_amount), 2) AS total_bill_amount,
ROUND(SUM(cb.total_conn_collected_amount), 2) AS total_collected_amount,
ROUND(SUM(cb.total_conn_bill_amount) - SUM(cb.total_conn_collected_amount), 2) AS pending_amount,
ROUND(
CASE
WHEN SUM(cb.total_conn_bill_amount) = 0 THEN 0.00
ELSE (SUM(cb.total_conn_collected_amount) / SUM(cb.total_conn_bill_amount)) * 100
END,
2
) AS collection_precentage
FROM service_packages p
INNER JOIN mobile_connections mc ON p.package_ref = mc.package_ref
INNER JOIN connection_bills cb ON mc.connection_ref = cb.connection_ref
LEFT JOIN connection_usage cu ON mc.connection_ref = cu.connection_ref
WHERE mc.connection_state = 'ACTIVE'
AND p.package_enabled = 1
GROUP BY p.package_ref, p.p
450 · import java.util.*;
public class TestClass {
public static int cureTheVirus(int n, int[] impact, int[] numOfPre, int[][] precells) {
int source = 0;
int sink = n + 1;
List<Edge>[] graph = new List[sink + 1];
for (int i = 0; i <= sink; i++) {
graph[i] = new ArrayList<>();
}
int totalPositiveImpact = 0;
for (int i = 0; i < n; i++) {
int w = impact[i];
int u = i + 1;
if (w > 0) {
totalPositiveImpact += w;
addEdge(graph, source, u, w);
} else if (w < 0) {
addEdge(graph, u, sink, -w);
}
for (int k = 0; k < numOfPre[i]; k++) {
int v = precells[i][k];
addEdge(graph, u, v, Integer.MAX_VALUE);
}
}
int minCut = dinicMaxFlow(graph, source, sink);
return totalPositiveImpact - minCut;
}
private static class Edge {
int to;
int rev;
int cap;
int flow;
Edge(int to, int rev, int cap) {
this.to = to;
this.rev = rev;
this.cap = cap;
this.flow = 0;
}
}
private static void addEdge(List<Edge>[] graph, int from, int to, int cap) {
Edge a = new Edge(to, graph[to].size(), cap);
Edge b = new Edge(from, graph[from].size(), 0);
graph[from].add(a);
graph[to].add(b);
}
private static int dinicMaxFlow(List<Edge>[] graph, int src, int dest) {
int flow = 0;
int[] level = new int[graph.length];
while (bfs(graph, src, dest, level)) {
int[] ptr = new int[graph.length];
while (true) {
int pushed = dfs(graph, src, dest, Integer.MAX_VALUE, level, ptr);
if (pushed == 0) {
break;
}
flow += pushed;
}
475 · import java.util.Scanner;
public class TestClass
{
static int countOccurrence(int n, String grid[], String word)
{
int count = 0;
int wordLen = word.length();
int[] dx = {-1, -1, -1, 0, 0, 1, 1, 1};
int[] dy = {-1, 0, 1, -1, 1, -1, 0, 1};
for (int r = 0; r < n; r++)
{
for (int c = 0; c < n; c++)
{
for (int dir = 0; dir < 8; dir++)
{
int k;
int currR = r;
int currC = c;
for (k = 0; k < wordLen; k++)
{
if (currR < 0 currR >= n currC < 0 || currC >= n)
{
break;
}
if (grid[currR].charAt(currC) != word.charAt(k))
{
break;
}
currR += dx[dir];
currC += dy[dir];
}
if (k == wordLen)
{
count++;
}
}
}
}
return count;
}
public static void main(String args[])
{
int n;
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
sc.nextLine();
String grid[] = new String[n];
for(int i=0; i<n; i++)
{
grid[i] = sc.nextLine();
}
String word;
word = sc.nextLine();
System.out.println(countOccurrence(n,grid,word));
}
}
FLIPKART✅
q4✅
690 · Фотография
нажмите — покажем
553 · нажмите — покажем
Фотография
нажмите — покажем
529 · нажмите — покажем