Given a string str. Calculate the total number of unique substrings of the given string.
Example 1:
Input:
abd
Ouput:
6
Explanation:
str = abd. The 6 unique substrings 
are {a, b, d, ab, bd, abd}.
Example 2:
Input:
jaja
Ouput:
7
Explanation:
str = jaja. The substrings will be j, a, j, a, 
ja, aj, ja, jaj, aja, jaja. Out of these the 
unique are j, a, ja, aj, jaj, aja, jaja.
User Task:
You need to complete the function unique_substring() that takes str as a parameter and returns the count of unique substrings.
Constraints:
1 <= |str| <= 100

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Starter code: #User function Template for python3

class Solution:
    def unique_substring(self,str):
        #code here


Solutions:
class Solution:

	def unique_substring(self, str):
		A = []
		n = len(str)
		i = 1
		while i <= n:
			for j in range(n):
				s = str[j:i + j]
				if len(s) == i:
					A.append(s)
			i = i + 1
		s = set(A)
		l = len(s)
		return l


class Solution:

	def unique_substring(self, str):
		l = set()
		n = len(str)
		for i in range(n):
			for j in range(i + 1, n + 1):
				l.add(str[i:j])
		return len(l)


class Solution:

	def unique_substring(self, str):
		strings = set()
		for i in range(len(str)):
			for j in range(i, len(str)):
				strings.add(str[i:j + 1])
		return len(strings)


class Solution:

	def unique_substring(self, s):
		setti = set()
		n = len(s)
		for i in range(n):
			for j in range(i + 1, n + 1):
				setti.add(s[i:j])
		return len(setti)


class Solution:

	def unique_substring(self, str):
		x = {}
		for i in range(len(str)):
			for j in range(i + 1, len(str) + 1):
				x[str[i:j]] = 1
		return len(x)


class Solution:

	def unique_substring(self, str):
		l = []
		n = len(str)
		for i in range(n):
			for j in range(0, n - i):
				l.append(str[i:j + i + 1])
		m = set(l)
		return len(m)


class Solution:

	def unique_substring(self, str):
		S = list(str)
		N = len(S)
		Subs = set()
		for length in range(N):
			for length2 in range(N - length):
				Subs.add(''.join(S[length2:length2 + length + 1]))
		return len(Subs)