Given N unique characters (in infinite supply), find the number of possible mapped strings of length N.
A mapped string follows following properties:
1. Both left and right halves of the string contains same set of characters.
2. Each half contains N / 2 unique characters.
For example: “abccba” is Mapped string since the left and right halves contain unique characters and both halves contain same set of characters but "abcbcd" is not.
As the answer can be very large, find it modulo 10^{9} + 7.
Note: N is always even.
Example 1:
Input: N = 2
Output: 2 
Explanation: Suppose two unique characters
are 'a' and 'b', then there will be two 
mapped strings - 'aa' and 'bb'.
Example 2:
Input: N = 4
Output: 24
Explanation: Suppose four unique characters
are 'a', 'b', 'c' and 'd' and for each pair of
them there will be four mapped strings. Hence, 
there are total 6 pairs so 6 * 4 = 24 total 
mapped strings.
Your Task:  
You dont need to read input or print anything. Complete the function mapStr() which takes N as input parameter and returns the number of possible mapped strings of length N.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Constraints:
2 ≤ N ≤ 100000

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Combinatorics

Data structures

Starter code: #User function Template for python3
class Solution:
    def mapStr (ob, N):
        # code here 

Solutions:
from math import factorial

class Solution:

	def mapStr(ob, N):
		return factorial(N) % (10 ** 9 + 7)


class Solution:

	def mapStr(ob, N):
		a = 1
		for i in range(1, N + 1):
			a = a * i
		c = a % 1000000007
		return c


class Solution:

	def mapStr(ob, N):
		p = 1
		for i in range(1, N + 1):
			p = p * i
			p = p % 1000000007
		return p


class Solution:

	def mapStr(ob, N):
		fact = 1
		for i in range(N, 0, -1):
			fact *= i
		return fact % (10 ** 9 + 7)


class Solution:

	def mapStr(ob, N):
		mod = 10 ** 9 + 7
		f = 1
		for i in range(1, N + 1):
			f *= i
		return f % mod


class Solution:

	def mapStr(ob, N):
		f = 1
		for i in range(1, N + 1):
			f *= i
		return f % 1000000007
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		N = int(N)
		ob = Solution()
		print(ob.mapStr(N))


class Solution:

	def fact(self, n):
		num = 1
		while n > 1:
			num *= n
			n -= 1
		return num

	def comb(self, n, r):
		num = 1
		i = 0
		while i < r:
			num *= n - i
			i += 1
		denm = self.fact(r)
		return num // denm

	def mapStr(ob, N):
		n = N // 2
		fact = ob.fact(n)
		comb = ob.comb(N, n)
		prime = 10 ** 9 + 7
		return comb % prime * (fact % prime) * (fact % prime) % prime


class Solution:

	def mapStr(ob, N):
		mod = 10 ** 9 + 7
		if N == 0:
			return 1
		else:
			sum = 1
			for i in range(1, N + 1):
				sum *= i % mod
			return sum % mod