human
Find the k | Function to find the Kth string in lexicographical order which consists of N - 2 xs and 2 ys.
Iterate for all possible positions of left most Y.
If i is the left most position of Y.
Put Y in their positions.
Driver code.
Function call"
Solution in Python:
assistant
#Here is code to find the k and the other steps required.
 def kth_string ( n , k ) :
	for i in range ( n - 2 , - 1 , - 1 ) :
		if k <= ( n - i - 1 ) :
			for j in range ( n ) :
				if ( j == i or j == n - k ) :
					print ( ' Y ' , end = " " )
				else :
					print ( ' X ' , end = " " )
			break
		k -= ( n - i - 1 )
n = 5
k = 7
kth_string ( n , k )