English
Open in Telegram

Postint solve(vector<int>& maze,int n)

12 June 2023
M
Machine Learning coder
int solve(vector<int>& maze,int n) { int maxSum=-1; for(int i=0; i<n; i++) { int node=i; int sum=0; unordered_set<int> visited; while(node < n && node >= 0 && i!=maze[node] && visited.count(node)==0) { visited.insert(node); sum+=node; node=maze[node]; } if(node>=0 && node < n && i == maze[node]) { maxSum=max(maxSum,sum); } } return maxSum; }
1.1K ·

Nearby in the feed

HHappyint minimumWeight(int n, vector<vector<int>>& edges, int C1, int C2) { vector<long long> A(n,LLONG_MAX), B(n,LLONG_MAX); Dijkstra(C1,graph,A); Dijkstra(C2,grapMMachine Learning coderNearest meeting cell
this message
MMachine Learning coderlargest sum cycleMMachine Learning coderint solution(vector<int>arr){ int ans=INT_MIN; int result=-1; vector<int>weight(arr.size(),0); for(int i=0;i<arr.size();i++){ int source=i; int dest=arr[i]; if(
DDeloitte | COGNIZANT | IBM | CAPGEMINIDeloitte | COGNIZANT | IBM | CAPGEMINI@python_java_Coding · channel · Tech
7 178subscribers406average post reach
Venue feed Open in Telegram

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · Index limits · Remove a page · Catalog · Search · How we count