# How to know if time complexity is O(n+m) or O(n*m)

I'm having difficulty understanding when can we know if the time complexity of an algorithm is n+m or n*m

Is the time complexity of the following algo O(n+m) or O(n*m)

Can you please point me to a resource that can give some sample examples of code patterns for different variations of time complexity?

For example:

for(String str : strs) {
char[] charArray = str.toCharArray();
Array.sort(charArray); //ignoring the TC of this one, which would be nLogn in java
System.out.println("sorted: "+ new String(charArray));
}