Minimum time to reach a point with + t and | C ++ implementation of the above approach ; returns the minimum time required to reach ' X ' ; Stores the minimum time ; increment ' t ' by 1 ; update the sum ; Driver code
#include <iostream> NEW_LINE using namespace std ; long cal_minimum_time ( long X ) { long t = 0 ; long sum = 0 ; while ( sum < X ) { t ++ ; sum = sum + t ; } return t ; } int main ( ) { long n = 6 ; long ans = cal_minimum_time ( n ) ; cout << " The ▁ minimum ▁ time ▁ required ▁ is ▁ : ▁ " << ans ; return 0 ; }