# Big O of runtime operation n-m+1 [duplicate]

This question already has an answer here:

I have a loop that runs n-m+1 times where

m = len(list_m)

n = len(list_n)

for i in range(n-m+1):


Is this time complexity O(n-m+1)?

## marked as duplicate by Raphael♦May 9 at 9:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

• What definition tells you? – Evil May 9 at 2:48
• We discourage posts that simply state a problem out of context, and expect the community to solve it. Assuming you tried to solve it yourself and got stuck, it may be helpful if you wrote your thoughts and what you could not figure out. It will definitely draw more answers to your post. Until then, the question will be voted to be closed / downvoted. You may also want to check out these hints, or use the search engine of this site to find similar questions that were already answered. – Raphael May 9 at 9:31
• What happens in the loop? What have you tried and where did you get stuck? Check out many other questions like this: runtime-analysis+loops. – Raphael May 9 at 9:32

## 1 Answer

If you are doing $$k$$ (i.e., constantly many) operations, each taking constant time $$O(1)$$, then the complexity will be on the order of $$O(k(n-m+1))$$, which is equivalent to $$O(n-m+1)$$. I recommend you to read this article or the Wikipedia page for the big-O notation.