/*Write either a C++ function int triplets(stack<string> words) or a Java method public static * int triplets(Stack<String> words) that take as the argument a stack of strings and count how * many elements are included in the stack exactly three times. You should use objects of type * set<string> in C++ or TreeSet<String> in Java. The set operations are given below (refer to * Problem 1 for the stack operations): */ #include <iostream> #include <stack> #include <set> #include <string> using namespace std; string popped=""; int triplets(stack<string>words) { set<string>set1{"wow", "AUA", "wow", "AUA", "Data Structures", "AUA", "OOP", "wow"} ; for(const auto &count: set1) { words.push(count); } for(int i=0; i<words.size(); i++) { for(int current=i; current<words.size(); current++) { popped=words.top(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)