{"id":13585,"date":"2023-03-30T18:13:58","date_gmt":"2023-03-30T12:13:58","guid":{"rendered":"https:\/\/shra.ru\/?p=13585"},"modified":"2023-03-30T18:14:29","modified_gmt":"2023-03-30T12:14:29","slug":"87-scramble-string-zadacha-o-peretasovannykh-strokakh","status":"publish","type":"post","link":"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/","title":{"rendered":"87. Scramble string — \u0437\u0430\u0434\u0430\u0447\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445"},"content":{"rendered":"\n

\u0420\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043b\u0438\u0442\u043a\u043e\u0434\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n\n\n\n

\u0414\u0430\u043d\u044b \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0431\u0443\u043a\u0432 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439. \u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n\n\n\n

\u041c\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 \u0434\u0432\u0435 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c SX \u0438 SY. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0438\u0442\u044c SX \u0438 SY \u043c\u0435\u0441\u0442\u0430\u043c\u0438, \u0430 \u043c\u043e\u0436\u0435\u043c \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f \u0434\u043b\u044f SX \u0438 SY, \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c.<\/p>\n\n\n\n\n\n\n\n

\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f baloon \u0438 onloba — \u043d\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0434\u0430\u0442\u044c true. \u0422.\u043a. \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 ‘ba’ \u0438 ‘loon’, \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u043c\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0441 ‘loon’ — \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 ‘lo’ \u0438 ‘on’ \u0438 \u0442\u043e\u0436\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n\n\n\n

[ba]-[loon] - \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b\u0438\n[loon]-[ba] - \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0438\u043b\u0438\n[[lo]-[on]]-[ba] - \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b\u0438 \u043f\u0435\u0440\u0432\u0443\u044e \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0443\n[[on]-[lo]]-[ba] - \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0447\u0430\u0441\u0442\u0438 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438\nonloba - \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/code><\/pre>\n\n\n\n

\u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 — baloon \u0438 oblona — \u0437\u0434\u0435\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0434\u0430\u0442\u044c false, \u0442.\u043a. \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043f\u0440\u0430\u0432\u0438\u043b \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0437 1\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c 2\u044e.<\/p>\n\n\n\n

\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n\n\n\n

\u041d\u0430 leetcode \u0432 \u0435\u0434\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u042d\u0442\u043e \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u043d\u043e \u0438\u0437-\u0437\u0430 \u043c\u043d\u043e\u0433\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f (\u0447\u0438\u0441\u043b\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 2) \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0435\u0433\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0438 \u043c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n\n\n\n

\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u044f<\/h3>\n\n\n\n

\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u044f\u043c\u043e \u0442\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0434\u0430\u043d\u044b \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n\n\n\n

\u041c\u044b \u0434\u0435\u043b\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 (\u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u044d\u0442\u043e S1) \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043a\u0430\u0436\u0434\u0430\u044f \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0434\u0432\u0430 \u0441\u043b\u0443\u0447\u0430\u044f — \u0441 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0431\u0435\u0437 \u044d\u0442\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438. <\/p>\n\n\n\n

\u041a\u043e\u0433\u0434\u0430 \u0434\u043b\u0438\u043d\u0430 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u0430 1, \u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0441\u0438\u043c\u0432\u043e\u043b \u043d\u0430 \u0442\u043e\u0439 \u0436\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 s2.<\/p>\n\n\n\n

\u0417\u0432\u0443\u0447\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434 (typescript).<\/p>\n\n\n\n

function isScramble(s1: string, s2: string): boolean {\n\n  \/\/ \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f (s, pos) \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \n  \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443, \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0437 S \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0443 \u0432 S2 \u0432 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 pos,\n  \/\/ \u043f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438\n  const check = (s: string, pos: number): boolean => {\n    const n = s.length;\n    \/\/ \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u043f\u0440\u0438 \u0434\u043b\u0438\u043d\u0435 == 1\n    if (n == 1) return s[0] == s2.charAt(pos)\n\n    \/\/ \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438\n    for (let i = 1; i < n; i++) {\n      \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438\n      const ns1 = s.substring(0, i), ns2 = s.substring(i)\n      \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438\n      if (check(ns1, pos) && check(ns2, pos + i)) return true\n      \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439\n      if (check(ns1, pos + n - i) && check(ns2, pos)) return true\n    }\n    \/\/ \u0435\u0441\u043b\u0438 \u043d\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043d\u0435 \u043f\u043e\u0434\u043e\u0448\u0435\u043b - \u0442\u043e \u0432\u0435\u0440\u043d\u0435\u043c false\n    return false\n  }\n\n  return check(s1, 0)\n};<\/code><\/pre>\n\n\n\n

\u041a\u043e\u0434 \u0440\u0430\u0431\u043e\u0447\u0438\u0439. \u041d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0435\u0433\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. <\/p>\n\n\n\n

\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0442\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u043e\u0447\u043d\u043e \u043d\u0435 \u0434\u0430\u0434\u0443\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0442.\u043a. \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0443\u0436\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432.<\/p>\n\n\n\n

\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441 baloon \u0438 onloba , \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 S1 \u043d\u0430 ‘bal’ \u0438 ‘oon’. \u041d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 S2 — ‘onl’, ‘oba’ \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0442\u0435\u0445 \u0436\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u0418 \u043a\u0430\u043a \u0431\u044b \u043c\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u044b\u0432\u0430\u043b\u0438 ‘bal’ , \u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c ‘onl’.<\/p>\n\n\n\n

\u042d\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0431\u043e\u0440, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u043d\u0435\u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0439 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438. \u041c\u044b \u043e\u0442\u0441\u0435\u043a\u0430\u0435\u043c \u0432\u0435\u0442\u043a\u0438 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0441 \u0437\u0430\u0432\u0435\u0434\u043e\u043c\u043e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0431\u0443\u043a\u0432.<\/p>\n\n\n\n

function isScramble(s1: string, s2: string): boolean {\n\n  const check = (s: string, pos: number): boolean => {\n    const n = s.length;\n    if (n == 1) return s[0] == s2.charAt(pos)\n\n    \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u043b\u0438 \u0442\u043e\u0442 \u0436\u0435 \u043d\u0430\u0431\u043e\u0440 \u0431\u0443\u043a\u0432 \n    \/\/ \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 s2, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 pos\n    const s1sort = s.split('').sort().join('')\n    const s2sort = s2.substring(pos, pos + n).split('').sort().join('');\n    if (s1sort != s2sort) return false\n\n    for (let i = 1; i < n; i++) {\n      const ns1 = s.substring(0, i), ns2 = s.substring(i)\n      if (check(ns1, pos) && check(ns2, pos + i)) return true\n      if (check(ns1, pos + n - i) && check(ns2, pos)) return true\n    }\n    return false\n  }\n\n  return check(s1, 0)\n};<\/code><\/pre>\n\n\n\n

\u0414\u043b\u044f \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0439 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043b\u043e, \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a \u0442\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438, \u0432\u0445\u043e\u0434\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0435\u0442\u043a\u0438 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u044f baloon, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0443 ‘oon’ \u043f\u0440\u0438 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0438 [bal] — [oon] \u0438 \u043f\u0440\u0438 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0438 [ba]-[loon] -> [ba]-[[l]-[oon]].<\/p>\n\n\n\n

\u041c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u0435\u0448, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0431\u0443\u0434\u0435\u043c, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 S \u0432 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 POS, \u0442\u0430\u043a \u043c\u044b \u043e\u0442\u0441\u0435\u0447\u0435\u043c \u0443\u0436\u0435 \u0440\u0430\u043d\u0435\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a.<\/p>\n\n\n\n

function isScramble(s1: string, s2: string): boolean {\n  \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u0435\u0448\u0435\u0439\n  \/\/ \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 POS \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439\n  const cache: Map<string, boolean>[] = []\n  for (let i = 0; i < s1.length; i++) cache[i] = new Map();\n\n  const check = (s: string, pos: number): boolean => {\n    const n = s.length;\n    if (n == 1) return s[0] == s2.charAt(pos)\n\n    const s1sort = s.split('').sort().join('')\n    \/\/ \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440\n    \/\/ \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0442\u0443\u0442 \u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432 \u043a\u0435\u0448\u0435\n    const hist = cache[pos].get(s1sort)\n    if (hist !== undefined) return hist\n\n    const s2sort = s2.substring(pos, pos + n).split('').sort().join('');\n\n    if (s1sort != s2sort) {\n      \/\/ \u043a\u0435\u0448\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\n      cache[pos].set(s1sort, false)\n      return false\n    }\n\n    for (let i = 1; i < n; i++) {\n      const ns1 = s.substring(0, i), ns2 = s.substring(i)\n      if (check(ns1, pos) && check(ns2, pos + i)) {\n        \/\/ \u043a\u0435\u0448\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\n        cache[pos].set(s1sort, true)\n        return true\n\n      }\n      if (check(ns1, pos + n - i) && check(ns2, pos)) {\n        \/\/ \u043a\u0435\u0448\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\n        cache[pos].set(s1sort, true)\n        return true\n\n      }\n    }\n\n    \/\/ \u043a\u0435\u0448\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\n    cache[pos].set(s1sort, false)\n    return false\n  }\n\n  return check(s1, 0)\n};<\/code><\/pre>\n\n\n\n

\u041a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Map \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0435\u0448\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430.<\/p>\n\n\n\n

\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c «\u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0437\u0432\u0435\u0437\u0434 \u0441 \u043d\u0435\u0431\u0430», \u043d\u043e \u0434\u0430\u0436\u0435 \u043f\u043e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435 leetcode \u0432\u044b\u0434\u0430\u0451\u0442 \u043d\u0435 \u043f\u043b\u043e\u0445\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n\n\n

\n
\"\"<\/figure><\/div>\n\n\n

\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043a\u0435\u0448 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043d\u043e \u043d\u0435 \u043f\u043b\u043e\u0445\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0432 \u0441\u043c\u044b\u0441\u043b\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u0415\u0441\u043b\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c\u044e \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043f\u0430\u043c\u044f\u0442\u0438, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0447\u0435\u043a \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u0438\u0445 4 \u0432 \u043a\u043e\u0434\u0435).<\/p>\n","protected":false},"excerpt":{"rendered":"

\u0420\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043b\u0438\u0442\u043a\u043e\u0434\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u043d\u044b \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0431\u0443\u043a\u0432 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439. \u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435: \u041c\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 \u0434\u0432\u0435 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c SX \u0438 SY. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0438\u0442\u044c SX \u0438 SY \u043c\u0435\u0441\u0442\u0430\u043c\u0438, \u0430 \u043c\u043e\u0436\u0435\u043c \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f \u0434\u043b\u044f SX \u0438 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[158],"class_list":["post-13585","post","type-post","status-publish","format-standard","hentry","category-programmirovanie","tag-razbor-zadach"],"acf":[],"yoast_head":"\n87. Scramble string - \u0437\u0430\u0434\u0430\u0447\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445<\/title>\n<meta name=\"description\" content=\"\u0420\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043b\u0438\u0442\u043a\u043e\u0434\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u043d\u044b \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0431\u0443\u043a\u0432 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439. \u041f\u0440\u0430\u0432\u0438\u043b\u0430\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/\" \/>\n<meta property=\"og:locale\" content=\"ru_RU\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"87. Scramble string - \u0437\u0430\u0434\u0430\u0447\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445\" \/>\n<meta property=\"og:description\" content=\"\u0420\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043b\u0438\u0442\u043a\u043e\u0434\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u043d\u044b \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0431\u0443\u043a\u0432 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439. \u041f\u0440\u0430\u0432\u0438\u043b\u0430\" \/>\n<meta property=\"og:url\" content=\"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/\" \/>\n<meta property=\"og:site_name\" content=\"Shra's homepage\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-30T12:13:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-30T12:14:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/shra.ru\/wp-content\/uploads\/2023\/03\/image-4.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0430\u0432\u0442\u043e\u0440\u043e\u043c\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u043c\u0438\u043d\u0443\u0442\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/\",\"url\":\"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/\",\"name\":\"87. Scramble string - \u0437\u0430\u0434\u0430\u0447\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445\",\"isPartOf\":{\"@id\":\"https:\/\/shra.ru\/#website\"},\"datePublished\":\"2023-03-30T12:13:58+00:00\",\"dateModified\":\"2023-03-30T12:14:29+00:00\",\"author\":{\"@id\":\"https:\/\/shra.ru\/#\/schema\/person\/55c78fbfda205fbab95564dcccc144e8\"},\"description\":\"\u0420\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043b\u0438\u0442\u043a\u043e\u0434\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u043d\u044b \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0431\u0443\u043a\u0432 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439. \u041f\u0440\u0430\u0432\u0438\u043b\u0430\",\"breadcrumb\":{\"@id\":\"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/#breadcrumb\"},\"inLanguage\":\"ru-RU\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\",\"item\":\"https:\/\/shra.ru\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"87. Scramble string — \u0437\u0430\u0434\u0430\u0447\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/shra.ru\/#website\",\"url\":\"https:\/\/shra.ru\/\",\"name\":\"Shra's homepage\",\"description\":\"\u041f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 shra, \u0431\u043b\u043e\u0433 \u0444\u0440\u0438\u043b\u0435\u043d\u0441\u0435\u0440\u0430, \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043d\u0430 PHP. \u0417\u0434\u0435\u0441\u044c \u044f \u0434\u0435\u043b\u044e\u0441\u044c \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0438 \u043c\u044b\u0441\u043b\u044f\u043c\u0438, \u043f\u0440\u043e\u0432\u043e\u0436\u0443 \u043e\u043f\u044b\u0442\u044b \u043d\u0430\u0434 \u043b\u044e\u0434\u044c\u043c\u0438, \u0441\u043e\u0431\u0438\u0440\u0430\u044e \u043d\u0435\u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0433\u043b\u0443\u043f\u043e\u0441\u0442\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0441 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430, \u0432\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0435 \u0432\u0441\u044e \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u0430\u0448\u0435 \u043f\u0441\u0438\u0445\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u0435 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u044b \u0442\u0440\u0435\u0442\u044c\u0438\u0445 \u043b\u0438\u0446.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/shra.ru\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"ru-RU\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/shra.ru\/#\/schema\/person\/55c78fbfda205fbab95564dcccc144e8\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ru-RU\",\"@id\":\"https:\/\/shra.ru\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/shra.ru\/wp-content\/uploads\/2021\/08\/shra_ava_margo_512-96x96.png\",\"contentUrl\":\"https:\/\/shra.ru\/wp-content\/uploads\/2021\/08\/shra_ava_margo_512-96x96.png\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/shra.ru\"],\"url\":\"https:\/\/shra.ru\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"87. Scramble string - \u0437\u0430\u0434\u0430\u0447\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445","description":"\u0420\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043b\u0438\u0442\u043a\u043e\u0434\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u043d\u044b \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0431\u0443\u043a\u0432 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439. \u041f\u0440\u0430\u0432\u0438\u043b\u0430","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/","og_locale":"ru_RU","og_type":"article","og_title":"87. Scramble string - \u0437\u0430\u0434\u0430\u0447\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445","og_description":"\u0420\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043b\u0438\u0442\u043a\u043e\u0434\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u043d\u044b \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0431\u0443\u043a\u0432 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439. \u041f\u0440\u0430\u0432\u0438\u043b\u0430","og_url":"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/","og_site_name":"Shra's homepage","article_published_time":"2023-03-30T12:13:58+00:00","article_modified_time":"2023-03-30T12:14:29+00:00","og_image":[{"url":"https:\/\/shra.ru\/wp-content\/uploads\/2023\/03\/image-4.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0430\u0432\u0442\u043e\u0440\u043e\u043c":"admin","\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f":"6 \u043c\u0438\u043d\u0443\u0442"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/","url":"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/","name":"87. Scramble string - \u0437\u0430\u0434\u0430\u0447\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445","isPartOf":{"@id":"https:\/\/shra.ru\/#website"},"datePublished":"2023-03-30T12:13:58+00:00","dateModified":"2023-03-30T12:14:29+00:00","author":{"@id":"https:\/\/shra.ru\/#\/schema\/person\/55c78fbfda205fbab95564dcccc144e8"},"description":"\u0420\u0435\u0448\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043b\u0438\u0442\u043a\u043e\u0434\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0414\u0430\u043d\u044b \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u0438 \u0431\u0443\u043a\u0432 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439. \u041f\u0440\u0430\u0432\u0438\u043b\u0430","breadcrumb":{"@id":"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/#breadcrumb"},"inLanguage":"ru-RU","potentialAction":[{"@type":"ReadAction","target":["https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/shra.ru\/2023\/03\/87-scramble-string-zadacha-o-peretasovannykh-strokakh\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430","item":"https:\/\/shra.ru\/"},{"@type":"ListItem","position":2,"name":"87. Scramble string — \u0437\u0430\u0434\u0430\u0447\u0430 \u043e \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445"}]},{"@type":"WebSite","@id":"https:\/\/shra.ru\/#website","url":"https:\/\/shra.ru\/","name":"Shra's homepage","description":"\u041f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 shra, \u0431\u043b\u043e\u0433 \u0444\u0440\u0438\u043b\u0435\u043d\u0441\u0435\u0440\u0430, \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043d\u0430 PHP. \u0417\u0434\u0435\u0441\u044c \u044f \u0434\u0435\u043b\u044e\u0441\u044c \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0438 \u043c\u044b\u0441\u043b\u044f\u043c\u0438, \u043f\u0440\u043e\u0432\u043e\u0436\u0443 \u043e\u043f\u044b\u0442\u044b \u043d\u0430\u0434 \u043b\u044e\u0434\u044c\u043c\u0438, \u0441\u043e\u0431\u0438\u0440\u0430\u044e \u043d\u0435\u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0433\u043b\u0443\u043f\u043e\u0441\u0442\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0441 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430, \u0432\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0435 \u0432\u0441\u044e \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u0430\u0448\u0435 \u043f\u0441\u0438\u0445\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u0435 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u044b \u0442\u0440\u0435\u0442\u044c\u0438\u0445 \u043b\u0438\u0446.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/shra.ru\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"ru-RU"},{"@type":"Person","@id":"https:\/\/shra.ru\/#\/schema\/person\/55c78fbfda205fbab95564dcccc144e8","name":"admin","image":{"@type":"ImageObject","inLanguage":"ru-RU","@id":"https:\/\/shra.ru\/#\/schema\/person\/image\/","url":"https:\/\/shra.ru\/wp-content\/uploads\/2021\/08\/shra_ava_margo_512-96x96.png","contentUrl":"https:\/\/shra.ru\/wp-content\/uploads\/2021\/08\/shra_ava_margo_512-96x96.png","caption":"admin"},"sameAs":["https:\/\/shra.ru"],"url":"https:\/\/shra.ru\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/shra.ru\/wp-json\/wp\/v2\/posts\/13585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shra.ru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shra.ru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shra.ru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shra.ru\/wp-json\/wp\/v2\/comments?post=13585"}],"version-history":[{"count":1,"href":"https:\/\/shra.ru\/wp-json\/wp\/v2\/posts\/13585\/revisions"}],"predecessor-version":[{"id":13588,"href":"https:\/\/shra.ru\/wp-json\/wp\/v2\/posts\/13585\/revisions\/13588"}],"wp:attachment":[{"href":"https:\/\/shra.ru\/wp-json\/wp\/v2\/media?parent=13585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shra.ru\/wp-json\/wp\/v2\/categories?post=13585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shra.ru\/wp-json\/wp\/v2\/tags?post=13585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}} <!-- Alpha cache content. Generated from cache in 0.018166065216064 s. DB queries count : 2 -->