+ 4
How to find time taken by our code?
some code output says time exceed
6 Réponses
+ 9
In java, you can use System.nanoTime() to get the current time of execution. Then just convert the nanoseconds to regular seconds.
You didn't ask for the language, soo :P.
+ 9
C++:
clock_t time = clock();
// Your code
cout << (double) (clock() - time) / CLOCKS_PER_SEC;
and don't forget #include <time.h>
Java:
Check out the main() function in this code.
https://code.sololearn.com/c10BAhXfFGbP/?ref=app
+ 4
language cpp
+ 4
use NPTEL video for time complexity
+ 3
generally we calculate time as function O(n) for loop O(n2) for two for loop O(n2) for tree. what is it? if anyone has list please give
+ 2
In c# you can make a stopwatch class, start it after user input and stop it at the end then call for elapsed time.