human
Check if it is possible to reach any point on the circumference of a given circle from origin | Function to check if it is possible to reach any point on circumference of the given circle from ( 0 , 0 ).
Stores the count of ' L ' , 'R.
Stores the count of ' U ' , 'D.
Traverse the string S.
Update the count of L.
Update the count of R.
Update the count of U.
Update the count of D.
Condition 1 for reaching the circumference.
Store the the value of ( i * i ) in the Map.
Check if ( r_square - i * i ) already present in HashMap.
If it is possible to reach the point ( mp [ r_square - i * i ] , i ).
If it is possible to reach the point ( i , mp [ r_square - i * i ] ).
If it is impossible to reach.
Driver Code"
Solution in Python:
assistant
#Here is code to check if it is possible to reach any point on the circumference of a given circle from origin and the other steps required.
 def isPossible ( S , R , N ) :
'
	cntl = 0
	cntr = 0
'
	cntu = 0
	cntd = 0
	for i in range ( N ) :
		if ( S [ i ] == ' L ' ) :
			cntl += 1
		elif ( S [ i ] == ' R ' ) :
			cntr += 1
		elif ( S [ i ] == ' U ' ) :
			cntu += 1
		else :
			cntd += 1
	if ( max ( max ( cntl , cntr ) , max ( cntu , cntd ) ) >= R ) :
		return " Yes "
	mp = { }
	r_square = R * R
	i = 1
	while i * i <= r_square :
		mp [ i * i ] = i
		if ( ( r_square - i * i ) in mp ) :
			if ( max ( cntl , cntr ) >= mp [ r_square - i * i ] and max ( cntu , cntd ) >= i ) :
				return " Yes "
			if ( max ( cntl , cntr ) >= i and max ( cntu , cntd ) >= mp [ r_square - i * i ] ) :
				return " Yes "
		i += 1
	return " No "
if __name__ == " _ _ main _ _ " :
	S = " RDLLDDLDU "
	R = 5
	N = len ( S )
	print ( isPossible ( S , R , N ) )