+ 2
Alternative for nested loop
Do you know a solution to replace nested loop to reach O(n) time complexity. here's the problem: for(i=0; i<10; i++) { for(j=0; j<10-i; j++) { Console.WriteLine(i.ToString() + " " + j.ToString()); } } and would you please give me the sample of solution code?
2 Respostas
+ 2
yes we can use nested for loop, but will reduce performance.
0
I think it depends on what you want to do with them, because, lets say you want to store numbers in a bidimensional array, you can use nested loops to reach every single position in the array, that is the easy and short way to do it.