C++ · problem solving

Hacker Rank “Sherlock and Anagrams”

  Given a string , find the number of "unordered anagrammatic pairs" of substrings. Input Format First line contains , the number of testcases. Each testcase consists of string in one line. Output Format For each testcase, print the required answer in one line. Sample Input#00 2 abba abcd Sample Output#00 4 0 Sample Input#01… Continue reading Hacker Rank “Sherlock and Anagrams”

Advertisements
C++ · problem solving

HackerRank “Super Reduce String”

Shil has a string, , consisting of lowercase English letters. In one operation, he can delete any pair of adjacent letters with same value. For example, string "" would become either "" or "" after operation. Shil wants to reduce as much as possible. To do this, he will repeat the above operation as many… Continue reading HackerRank “Super Reduce String”

C++ · Data Structure · problem solving

C++ STL

The C++ STL (Standard Template Library) is a powerful set of C++ template classes to provides general-purpose templatized classes and functions that implement many popular and commonly used algorithms and data structures like vectors, lists, queues, and stacks. At the core of the C++ Standard Template Library are following three well-structured components: Component Description Containers… Continue reading C++ STL

C++ · problem solving

USACO 1.1.1 Your Ride Is Here

/* ID: ahmedye1 PROG: ride LANG: C++ */ #include <iostream> #include <fstream> using namespace std; int main() { ifstream inputFile ("ride.in"); ofstream outputFile ("ride.out"); string groupName; string cometName; int groupNum = 1; int cometNum = 1; if (inputFile.is_open()) { inputFile >> cometName >> groupName; for (int i = 0; i < cometName.length(); i++) cometNum *=… Continue reading USACO 1.1.1 Your Ride Is Here