English
Open in Telegram

Postint solution(vector<int>arr){

12 June 2023
M
Machine Learning coder
int 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(dest!=-1){ weight[dest]+=source; if(ans<=weight[dest]){ ans=max(ans,weight[dest]); result=dest; } } } if(ans!=INT_MIN) return result; return -1; }
1.1K ·

Nearby in the feed

MMachine Learning coderint 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 >MMachine Learning coderlargest sum cycle
this message
MMachine Learning coderMaximum weight nodeHHappyimport collections v=int(input()) l=list(map(int,input().split())) d=collections.defaultdict(int) for k,v in enumerate(l): if v!=-1: d[v]+=k req=max(d.values())
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