Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ I need help asap! 2. Suspicious Activity From Logs Application logs are useful in analyzing interaction with an application and may also be used

C++ I need help asap!
image
image
image
image

2. Suspicious Activity From Logs Application logs are useful in analyzing interaction with an application and may also be used to detect suspicious activities. A log file is provided as a string array where each entry represents a money transfer in the form sender_user_id recipient_user_id amount . Each of the values is separated by a space. . . sender_user_id and recipient_user_id both consist only of digits, are at most 9 digits long and start with non-zero digit amount consists only of digits, is at most 9 digits long and starts with non-zero digit Logs are given in no particular order. Write a function that returns an array of strings denoting user_id s of suspicious users who were involved in-at least threshold number of log entries. The id s should be ordered ascending by numeric value. Example logs = [ 88 99 200 , 88 99 300 , 99 32 100 , 12 12 151 threshold = 2 The transactions count for each user, regardless of role are: ID 99 88 12 32 Transactions 3 2 1 1 There are two users with at least threshold = 2 transactions: 99 and 88. In ascending order, the return array is [ 88, 99 ]. Note: In the last log entry, user 12 was on both sides of the transaction. This counts as only 1 transaction for user 12. Function Description Complete the function processLogs in the editor below. The function has the following parameter(s): string logs[n]: each logs[i] denotes the ith entry in the logs int threshold: the minimum number of transactions that a user must have to be included in the result Returns: string]: an array of user id s as strings, sorted ascending by numeric value Constraints 1 n 105 . . 1 threshold n The sender_user_id, recipient_user_id and amount contain only characters in the range ascii[ 0 - 9 ]. The sender_user_id, recipient_user_id and amount start with a non-zero digit. 0 length of sender_user_id, recipient_user_id, amount 9. < The result will contain at least one element. Input Format Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains the integer, n, the size of logs. The following n lines contain a string, logs[i]. The last line contains an integer, threshold. Sample Case 0 Sample Input STDIN ---- 4 1 2 50- 1 7 70 13, 20 22 17 2 1 2 Function logs [] size n = 4 logs = [ 1,2 50 , 1 7 70 , 1 3 20 , 2 2 17 ] Sample Output ID @22713 Explanation threshold = 2 Transactions 3 2 1. 1 Only users 1 and 2 have at least threshold = 2 transactions. The return array in numerically ascending order is [ 1 , 2 ]. Note that in the last log entry, the user with id 2 performed both roles in the transaction. This is counted as one transaction for the user. Sample Case 1 Sample Input STDIN - 4 logs [] size n = 4 9 7 50 logs = [ 9 7 50 , 22 7 20 , 33 7 50 , 22 7 30 ] 22 7 20 33 7 50 22 7 30 3 7 Sample Output ID Function Explanation -- 9 threshold = 3 7 22 33 Transactions 1 4 2 Only user 7 has 3 or more transactions. The return array is [ 7 ].

Step by Step Solution

3.47 Rating (154 Votes )

There are 3 Steps involved in it

Step: 1

Answer def processLogslogs threshold Create a dictionary to store the transactio... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Canadian Income Taxation Planning And Decision Making

Authors: Joan Kitunen, William Buckwold

17th Edition 2014-2015 Version

1259094332, 978-1259094330

More Books

Students also viewed these Electrical Engineering questions

Question

13. Let X be exponential with mean 1/; that is, fX (x) = ex , 0 1].

Answered: 1 week ago