3 ms·Assuming you're using a non-backtracking library, they should both be O(n).by Blackthorn 4y agoAssuming you're using a non-backtracking library, they should both be O(n).