Given angle theta, find a possible time (in hh:mm format) when angle between hour hand and clock hand is theta. If no such time exists then print -1.
Input : theta = 90.0 Output : 3:0
Input : theta = 60.0 Output : 2:0
We have discussed how to find angle for given time in below post.
In this problem, we are asked to do revers. Since there are 12 possibilities for hour and 60 possibilities for minute, we loop through all possible time which is 12*60 = 720, if angle for any time is equal to given theta then we print that time.
Time Complexity : O(1)
Auxiliary Space : O(1)
This article is contributed by Pratik Chhajer. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Find time when hour and minute hands superimpose
- Time when minute hand and hour hand coincide
- Python program to convert time from 12 hour to 24 hour format
- C++ program to convert time from 12 hour to 24 hour format
- Convert time from 24 hour clock to 12 hour clock format
- Find other two sides of a right angle triangle
- Program to find the Interior and Exterior Angle of a Regular Polygon
- Program to find the time after K minutes from given time
- Number of handshakes such that a person shakes hands only once
- Hour-glass Pattern
- Time difference between expected time and given time
- Angle between two Planes in 3D
- Arc length from given Angle
- Check if it is possible to create a polygon with a given angle
- Changing One Clock Time to Other Time in Minimum Number of Operations