Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

if i use the bruth-force method, not the KMP algorithm, the best time is O(m), the worst time is O(mn). (m is length of longer string, n is the length of another string). What's the average time complexity and why?

Why would you care about average time complexity? The time complexity measure assumes worst case and it's O(N^2) in brute force case.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.