Created
April 22, 2022 16:37
-
-
Save technikhil314/adde52466934b3b0cf09fa2db5fb44e9 to your computer and use it in GitHub Desktop.
Revisions
-
technikhil314 renamed this gist
Apr 22, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
technikhil314 created this gist
Apr 22, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ function processLogs(logs, threshold) { const n = logs.length; let transactionCountMap = new Map() for(let i=0;i<n;i++) { const log = logs[i]; const [sender, recepient, amount] = log.split(" "); transactionCountMap.set(sender, (transactionCountMap.get(sender) || 0) + 1) if(sender !== recepient) { transactionCountMap.set(recepient, (transactionCountMap.get(recepient) || 0) + 1) } } const transactionCountEntries = Array.from(transactionCountMap.entries()); const overThreshholdUsers = transactionCountEntries.filter(x => x[1] >= threshold).map(x => x[0]); return overThreshholdUsers.sort((x,y) => parseInt(x)-parseInt(y) > 0 ? 1 : -1) }