![]() |
VOOZH | about |
Given an array of n words. Some words are repeated twice, we need to count such words.
Examples:
Input : s[] = {"hate", "love", "peace", "love",
"peace", "hate", "love", "peace",
"love", "peace"};
Output : 1
There is only one word "hate" that appears twice
Input : s[] = {"Om", "Om", "Shankar", "Tripathi",
"Tom", "Jerry", "Jerry"};
Output : 2
There are two words "Om" and "Jerry" that appear
twice.
Source: Amazon Interview
Below is the implementation:
1
Time Complexity : O(N)
Auxiliary Space: O(N)
Below is the implementation:
1
Time Complexity : O(n)
Auxiliary Space: O(n)