C++ algorithm in one place, This is dedicated repository for maintaining data structures and algorithm code. This repository will be helpful for students preparing for internships or campus placements. Topics
Initially calculate the hash value of the pattern.
Start iterating from the starting of the string:
Calculate the hash value of the current substring having length m.
If the hash value of the current substring and the pattern are same check if the substring is same as the pattern.
If they are same, store the starting index as a valid answer. Otherwise, continue for the next substrings.
Return the starting indices as the required answer.
Initially calculate the hash value of the pattern. Start iterating from the starting of the string: Calculate the hash value of the current substring having length m. If the hash value of the current substring and the pattern are same check if the substring is same as the pattern. If they are same, store the starting index as a valid answer. Otherwise, continue for the next substrings. Return the starting indices as the required answer.