commit a61a701e012c4e98d2170b2594fda2cc46c635b7 Author: wuuconix <1521900139@qq.com> Date: Sun Jun 5 18:51:15 2022 +0800 add bf.js diff --git a/bf.js b/bf.js new file mode 100644 index 0000000..b6acb53 --- /dev/null +++ b/bf.js @@ -0,0 +1,13 @@ +const bf = (x, y) => { + const n = x.length, m = y.length + for (let i = 0; i <= n - m; i++) { + for (let j = 0; j < m; j++) { + if (x[i + j] == y[j] && j == m - 1) { + console.log(i) + } else if (x[i + j] != y[j]) { + break + } + } + } +} +bf("wuuconix", "conix") \ No newline at end of file