Use hash table with customer ID as key.
There can be three components in value: 1. num_days 2. pages 3. flag

For each line, calculate hash, find value for given key.
Increment appropriate values (i.e. pages or num_days).
If num_days > 1 && pages >1, add this customer to result array, mark
this customer's flag and don't process that customer  further.




On Sun, Jun 6, 2010 at 2:52 PM, amit <[email protected]> wrote:
> Google has many visitors to its site. And it tracks what pages the
> customers visited, etc and other stuff. Lets say you store the data of
> customer id and the page id as a record in a log-file. Now assuming
> that you have created one log file for each day with that above data-
> format. Give me the way to find all the customers who made a visit on
> day1 and day2 and visited atleast two different pages. Say a customer
> visited two different pages on day1 and then comes back on day2 and
> visited some other page on day2 he should be listed.
>
> Lets say the logfile1 has contents like:
> c1 p1
> c2 p2
> c1 p3
> c3 p4
> c5 p6
>
> And logfile2 has contents:
> c10 c7
> c4 p4
> c3 p4
> c5 p1
> c1 p2
> c2 p1
>
> Then the customers you print out are c1, c2, c5.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to