human
Count Distinct Strings present in an array using Polynomial rolling hash function | Function to find the hash value of a.
Traverse the.
Update hash_val.
Update mul.
Return hash_val of str.
Function to find the count of distinct strings present in the given array.
Store the hash values of the strings.
Traverse the array.
Stores hash value of arr [ i ].
Sort hash [ ] array.
Stores count of distinct strings in the array.
Traverse hash [ ] array.
Update cntElem.
Driver Code"
Solution in Python:

Write me a code to count Distinct Strings present in an array using Polynomial rolling hash function and the other steps required?
assistant
#Here is code to count Distinct Strings present in an array using Polynomial rolling hash function and the other steps required.
 def compute_hash ( str ) :
	p = 31
	MOD = 10 ** 9 + 7
	hash_val = 0
	mul = 1
	for ch in str :
		hash_val = ( hash_val + ( ord ( ch ) - ord ( ' a ' ) + 1 ) * mul ) % MOD
		mul = ( mul * p ) % MOD
	return hash_val
def distinct_str ( arr , n ) :
	hash = [ 0 ] * ( n )
	for i in range ( n ) :
		hash [ i ] = compute_hash ( arr [ i ] )
	hash = sorted ( hash )
	cntElem = 1
	for i in range ( 1 , n ) :
		if ( hash [ i ] != hash [ i - 1 ] ) :
			cntElem += 1
	return cntElem
if __name__ == ' _ _ main _ _ ' :
	arr = [ " abcde " , " abcce " , " abcdf " , " abcde " ]
	N = len ( arr )
	print ( distinct_str ( arr , N ) )