Skip to main content
re-fix grammar error, and clarify nomenclature
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158

Certainly the while loop is linear in size of article string s. But you're restarting that linear .index() search from the beginning each time, leading to nested loop \$O(N × M)\$ behavior if contentthe censored c appears \$M\$ times within the article. Given \$M << N\$ an efficient algorithm should see article size dominate the cost, with negligible contribution from the censoring operations.

Usually we give 0 and 1 a pass when it comes to calling out magic numbers. But here isn't neededit obscures Author's Intent, there's no need for such cryptic indexes. Prefer a tuple unpack:

Certainly the while loop is linear in size of article string s. But you're restarting that linear .index() search from the beginning each time, leading to nested loop \$O(N × M)\$ behavior if content c appears \$M\$ times within the article. Given \$M << N\$ an efficient algorithm should see article size dominate the cost, with negligible contribution from the censoring operations.

Usually we give 0 and 1 a pass when it comes to calling out magic numbers. But here isn't needed, there's no need for such cryptic indexes. Prefer a tuple unpack:

Certainly the while loop is linear in size of article string s. But you're restarting that linear .index() search from the beginning each time, leading to nested loop \$O(N × M)\$ behavior if the censored c appears \$M\$ times within the article. Given \$M << N\$ an efficient algorithm should see article size dominate the cost, with negligible contribution from the censoring operations.

Usually we give 0 and 1 a pass when it comes to calling out magic numbers. But here it obscures Author's Intent, there's no need for such cryptic indexes. Prefer a tuple unpack:

Rollback to Revision 6
Source Link
Peilonrayz
  • 44.6k
  • 7
  • 80
  • 158

Certainly the while loop is linear in size of article string s. But you're restarting that linear .index() search from the beginning each time, leading to nested loop \$O(N × M)\$ behavior if the censoredcontent c appears \$M\$ times within the article. Given \$M << N\$ an efficient algorithm should see article size dominate the cost, with negligible contribution from the censoring operations.

Usually we give 0 and 1 a pass when it comes to calling out magic numbers. But here it's just sillyisn't needed, there's no need for such cryptic indexes. Prefer a tuple unpack:

Certainly the while loop is linear in size of article string s. But you're restarting that linear .index() search from the beginning each time, leading to nested loop \$O(N × M)\$ behavior if the censored c appears \$M\$ times within the article. Given \$M << N\$ an efficient algorithm should see article size dominate the cost, with negligible contribution from the censoring operations.

Usually we give 0 and 1 a pass when it comes to calling out magic numbers. But here it's just silly, there's no need for such cryptic indexes. Prefer a tuple unpack:

Certainly the while loop is linear in size of article string s. But you're restarting that linear .index() search from the beginning each time, leading to nested loop \$O(N × M)\$ behavior if content c appears \$M\$ times within the article. Given \$M << N\$ an efficient algorithm should see article size dominate the cost, with negligible contribution from the censoring operations.

Usually we give 0 and 1 a pass when it comes to calling out magic numbers. But here isn't needed, there's no need for such cryptic indexes. Prefer a tuple unpack:

fix grammar error introduced by earlier SPAG edit
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158

Certainly the while loop is linear in size of article string s. But you're restarting that linear .index() search from the beginning each time, leading to nested loop \$O(N × M)\$ behavior if contentthe censored c appears \$M\$ times within the article. Given \$M << N\$ an efficient algorithm should see article size dominate the cost, with negligible contribution from the censoring operations.

Usually we give 0 and 1 a pass when it comes to calling out magic numbers. But here isn't neededit's just silly, there's no need for such cryptic indexes. Prefer a tuple unpack:

Certainly the while loop is linear in size of article string s. But you're restarting that linear .index() search from the beginning each time, leading to nested loop \$O(N × M)\$ behavior if content c appears \$M\$ times within the article. Given \$M << N\$ an efficient algorithm should see article size dominate the cost, with negligible contribution from the censoring operations.

Usually we give 0 and 1 a pass when it comes to calling out magic numbers. But here isn't needed, there's no need for such cryptic indexes. Prefer a tuple unpack:

Certainly the while loop is linear in size of article string s. But you're restarting that linear .index() search from the beginning each time, leading to nested loop \$O(N × M)\$ behavior if the censored c appears \$M\$ times within the article. Given \$M << N\$ an efficient algorithm should see article size dominate the cost, with negligible contribution from the censoring operations.

Usually we give 0 and 1 a pass when it comes to calling out magic numbers. But here it's just silly, there's no need for such cryptic indexes. Prefer a tuple unpack:

deleted 14 characters in body
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158
Loading
deleted 14 characters in body
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158
Loading
Restore original phrasing; I said what I meant to say in the way I intended. Thank you, I kept the beautiful LaTeX markup.
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158
Loading
Minor SPAG
Source Link
Peilonrayz
  • 44.6k
  • 7
  • 80
  • 158
Loading
deleted 68 characters in body
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158
Loading
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158
Loading