#### Category : search

I’m new to C++. I’m writing a program that searches an array of Chars for 3 Chars based on the user’s input. For some reason, I don’t have any output. Could you tell me where my logical error is, please? Here’s my code: #include <iostream> #include <cstdlib> using namespace std; string input; void searchArray(char a, ..

I was practicing questions on modified binary search and I came across a question https://practice.geeksforgeeks.org/problems/rotation4723/1# I wrote a code for it and tried few test cases on it and it worked as expected. This is the code which I wrote. int findKRotation(int arr[], int n) { int start = 0; int end = n – ..

I am building an Anti-Virus as a project, which works only statically (by matching the file signatures (hashes) to a db of known samples. My problem is that how can this be done properly? I have read that Aho-Corasick algorithm is used in this kind of matching [1, 2]. I have used this code [3], ..

Given a sorted list of integers, find all distinct pair of integers in the list of N integers with sum equal to a given number K with O(n log n) or O(n) time complexity. Write a function which takes the array and K as parameters and return the number of pairs if any and 0 ..

std::multimap<std::string, std::string> authors; authors.insert ({{"Steven,King", "Cujo"}, {"Jesse,James", "The Highlight"}}); auto it = authors.begin(); auto retVal2 = authors.erase(it+1); for (auto &i : authors){ std::cout << i.first << " " << i.second << std::endl; } Is it not allowed to add values to the iterator to move to the desired location in the multimap? In vectors this ..

I attempted the below problem to construct Binary Tree given the Preorder and Inorder Traversal arrays, Since the construction of left and right subtree of any given node requires finding the position of that node in Inorder Traversal array which renders an Overall Time Complexity of O(n^2) to solution . I attempted to optimize the ..

hey gays i try to solve a problem that require to make a program that search for number k in n strings in array and all his previous numbers including zero and finally calculate how many strings in array have these numbers . for example if the input is 2 strings ("0123","012") and search for ..