“Hello World” is a constant so it is O(1)
whereas string str
is variable of length n
so the complexity is O(n)
2
solved Time complexity difference in System.out.println() [closed]
“Hello World” is a constant so it is O(1)
whereas string str
is variable of length n
so the complexity is O(n)
2
solved Time complexity difference in System.out.println() [closed]