We will use C++ STL map for this one. For more info about map go here.
No need for arrays ,we keep only one map of type <int,int> where A[I] tells how many times we encountered the number I. We just input the first two blocks and increment the corresponding map element by 1. Then when we read the third block we input and check if we have faced the current number 2 times with the help our map, if yes then we increment answer by 1.
No need for arrays ,we keep only one map of type <int,int> where A[I] tells how many times we encountered the number I. We just input the first two blocks and increment the corresponding map element by 1. Then when we read the third block we input and check if we have faced the current number 2 times with the help our map, if yes then we increment answer by 1.
No comments:
Post a Comment