{"id":167177,"date":"2013-01-31T13:26:03","date_gmt":"2013-01-31T09:26:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=167177"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=167177","title":{"rendered":"<span class=\"post_title\">\u041f\u043e\u0438\u0441\u043a \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0417\u0430\u0434\u0430\u0447\u0430: \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0434\u043b\u0438\u043d\u043e\u0439 <i>N<\/i> \u043d\u0430\u0439\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 <i>N<\/i>\/2 \u0440\u0430\u0437.<\/p>\n<p>  \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0447\u0435\u0433\u043e \u0442\u0443\u0442 \u0434\u0443\u043c\u0430\u0442\u044c? \u0412\u043e\u0437\u044c\u043c\u0451\u043c Dictionary&lt;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0439&gt;, \u0437\u0430 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0441\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0438\u0437 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430 <i>O<\/i>(<i>N<\/i>), \u043a\u0443\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0435\u0449\u0451 \u0431\u044b\u0441\u0442\u0440\u0435\u0435?<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/267\/705\/51e\/26770551ed1bc6ca46b744dc85ed0de6.jpg\"\/><br \/>  \u0415\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043d\u044e\u0430\u043d\u0441: \u0434\u043b\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <i>O<\/i>(<i>N<\/i>) \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u2014 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0438 \u044d\u0442\u043e \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0445\u043e\u0442\u044c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439, \u0445\u043e\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e\u043c. \u0427\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043d\u0430\u0448\u0430 \u0446\u0435\u043b\u044c \u2014 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043d\u0435\u043a\u0438\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0441 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e? \u041c\u0430\u0441\u0441\u0438\u0432 \u2014 \u0437\u0430\u043c\u0435\u0440\u044b \u0443\u0440\u043e\u0432\u043d\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u0430, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0434\u0438\u043d \u2014 \u00ab\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439\u00bb \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u2014 \u0448\u0443\u043c \u0438 \u043f\u043e\u043c\u0435\u0445\u0438. \u041d\u0435\u0443\u0436\u0435\u043b\u0438 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u00ab\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e\u00bb \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043e\u0437\u0438\u0442\u044c\u0441\u044f \u0441 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u0438 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u043c\u0438?<\/p>\n<p>  \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043d\u0435\u0442: \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e <i>O<\/i>(1) \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0438 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443. <a name=\"habracut\"><\/a> \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0411\u043e\u0439\u0435\u0440\u0430-\u041c\u0443\u0440\u0430 \u2014 \u0442\u0435\u0445 \u0441\u0430\u043c\u044b\u0445 \u0411\u043e\u0439\u0435\u0440\u0430 \u0438 \u041c\u0443\u0440\u0430, \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC_%D0%91%D0%BE%D0%B9%D0%B5%D1%80%D0%B0_%E2%80%94_%D0%9C%D1%83%D1%80%D0%B0\">\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438<\/a> \u2014 \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c <a href=\"http:\/\/stackoverflow.com\/questions\/7059780\/find-the-element-repeated-more-than-n-2-times\">\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c<\/a>: <i>\u043d\u0430 \u0432\u0435\u0447\u0435\u0440\u0438\u043d\u043a\u0435 \u0441\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c <\/i>N<i> \u043b\u044e\u0434\u0435\u0439, \u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u043e\u0435, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0440\u0430\u0437\u043d\u044b\u0435, \u043e\u043d\u0438 \u043f\u0440\u0438\u0441\u0430\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u044d\u0442\u043e \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432 \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u0441\u0442\u043e\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u044e\u0434\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438; \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u044d\u0442\u043e \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 <\/i>N<i>\/2 \u0440\u0430\u0437.<\/i><\/p>\n<p>  <a href=\"http:\/\/keithschwarz.com\/interesting\/code\/?dir=majority-element\">\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/a> \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0411\u043e\u0439\u0435\u0440\u0430-\u041c\u0443\u0440\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a:  <\/p>\n<pre><code>int* majority(int[] array, int N) {   int confidence = 0; \/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u044e\u0434\u0435\u0439, \u043d\u0435 \u043d\u0430\u0448\u0435\u0434\u0448\u0438\u0445 \u043f\u0430\u0440\u044b \u0438 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u0441\u0442\u043e\u044f\u0442\u044c   int* candidate = NULL; \/\/ \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u043d\u0435 \u043d\u0430\u0448\u0435\u0434\u0448\u0438\u0439 \u043f\u0430\u0440\u0443 --                           \/\/ \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e    \/\/ \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0438 \u0443\u0441\u0430\u0436\u0438\u0432\u0430\u0435\u043c \u043f\u0430\u0440\u044b \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438   for (int i = 0; i&lt;N; i++) {      \/\/ \u0435\u0441\u043b\u0438 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0432\u0441\u0435 \u0441\u0438\u0434\u044f\u0442, \u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u043e\u043a\u0430 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u0442\u044c     if (confidence == 0) {       candidate = array+i;       confidence++;     }      \/\/ \u0438\u043d\u0430\u0447\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043b\u0438\u0431\u043e \u0441\u0430\u0434\u0438\u0442\u0441\u044f \u0441 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0442\u043e\u044f\u0449\u0438\u0445,     \/\/ \u043b\u0438\u0431\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u043e\u044f\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0435\u0433\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442     else if (*candidate == array[i]))        confidence++;     else        confidence--;   }    return confidence &gt; 0 ? candidate : NULL; } <\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u00ab\u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u0430\u00bb \u043d\u0430 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432 <i>N<\/i>\/2 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u0445: \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0439\u0434\u0435\u043d; \u0435\u0441\u043b\u0438 \u0436\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0435\u0442, \u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u0442\u043e\u044f\u0442\u044c \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0431\u0435\u0434\u043e\u043b\u0430\u0433\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u043b\u043e \u043f\u0430\u0440\u044b. \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u043e\u0433\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>majority<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437.<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/24d\/af5\/75c\/24daf575c26cc4b47ca508073d5f6746.jpg\"\/><\/p>\n<p>  \u0423\u0441\u043b\u043e\u0436\u043d\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443. \u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0434\u043b\u0438\u043d\u043e\u0439 <i>N<\/i> \u043d\u0430\u0434\u043e \u043d\u0430\u0439\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 <i>N<\/i>\/3 \u0440\u0430\u0437 \u2014 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0434\u0432\u0430, \u0442\u043e \u043e\u0431\u0430, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d, \u0442\u043e \u043e\u0434\u0438\u043d.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0448\u0435\u043c\u0443 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u0441 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u0441 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c\u0438 \u0443\u0440\u043e\u0432\u043d\u044f\u043c\u0438 \u043d\u0443\u043b\u044f \u0438 \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u043e\u043b\u044c, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u2014 \u0435\u0434\u0438\u043d\u0438\u0446\u0430, \u0430 \u043b\u044e\u0431\u044b\u0435 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u0442 \u043d\u0438\u0445 \u0443\u0440\u043e\u0432\u043d\u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u2014 \u044d\u0442\u043e \u043f\u043e\u043c\u0435\u0445\u0438 \u0438 \u0434\u0440\u0435\u0431\u0435\u0437\u0433 \u043e\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0418\u0434\u0435\u044e \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0431\u0449\u0438\u0442\u044c \u0438 \u0434\u043b\u044f \u0442\u0440\u043e\u0435\u043a: \u043f\u0443\u0441\u0442\u044c \u043b\u044e\u0434\u0438 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0440\u0430\u0441\u0441\u0430\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u0442\u0440\u043e\u0435. \u0417\u043d\u0430\u0447\u0438\u0442, \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u0435\u0447\u0435\u0440\u0438\u043d\u043a\u0438 \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u0441\u0442\u043e\u044f\u0442\u044c \u043b\u044e\u0434\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0441 \u0434\u0432\u0443\u043c\u044f \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 <i>N<\/i>\/3 \u0440\u0430\u0437, \u0437\u043d\u0430\u0447\u0438\u0442 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0441 \u043d\u0438\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u044f\u0442\u044c, \u0432\u0435\u0434\u044c \u0441\u0438\u0434\u044f\u0449\u0438\u0445 \u0442\u0440\u043e\u0435\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 <i>N<\/i>\/3. \u041a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0438\u0441\u043a\u043e\u043c\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u2014 \u0442\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0439\u0434\u0435\u043d\u044b, \u043d\u043e \u0435\u0441\u043b\u0438 \u0438\u0445 \u043d\u0435\u0442 \u2014 \u0442\u043e \u043d\u0430\u0439\u0442\u0438\u0441\u044c \u043c\u043e\u0436\u0435\u0442 \u043a\u0442\u043e \u043f\u043e\u043f\u0430\u043b\u043e.<\/p>\n<p>  \u041a\u043e\u0434 \u043c\u0430\u043b\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e: \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0438 <i>O<\/i>(1) \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.  <\/p>\n<pre><code>void majority(int[] array, int N, int** cand1, int** cand2) {   int conf1 = 0, conf2 = 0; \/\/ \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u043e\u044f\u0449\u0438\u0445 \u043b\u044e\u0434\u0435\u0439 \u0441 \u0434\u0432\u0443\u043c\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438   *cand1 = NULL; *cand2 = NULL; \/\/ \u0434\u0432\u0430 \u0441\u0442\u043e\u044f\u0449\u0438\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438    \/\/ \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0438 \u0443\u0441\u0430\u0436\u0438\u0432\u0430\u0435\u043c \u0442\u0440\u043e\u0439\u043a\u0438 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438   for (int i = 0; i&lt;N; i++) {      \/\/ \u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u0430\u043a \u0443 \u0441\u0442\u043e\u044f\u0449\u0438\u0445? \u0442\u043e\u0433\u0434\u0430 \u0432\u0441\u0442\u0430\u043d\u0435\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438     if (conf1 &gt; 0 && **cand1 == array[i])       conf1++;     else if (conf2 &gt; 0 && **cand2 == array[i])       conf2++;     else \/\/ \u043c\u043e\u0436\u0435\u0442, \u0441\u0442\u043e\u044f\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u0434\u043d\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c, \u0438\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0441\u0442\u043e\u044f\u0449\u0438\u0445 \u043d\u0435\u0442?       if (conf1 == 0) {         *cand1 = array+i;         conf1++;       } else if (conf2 == 0) {         *cand2 = array+i;         conf2++;       }     else { \/\/ \u0441\u0442\u043e\u044f\u0442 \u0441 \u0434\u0432\u0443\u043c\u044f \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u0443\u0441\u0430\u0436\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u044e \u0442\u0440\u043e\u0439\u043a\u0443       conf1--;       conf2--;     }   }    if(conf1 == 0) *cand1 = NULL;   if(conf2 == 0) *cand2 = NULL; } <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c <a href=\"http:\/\/www.cs.utexas.edu\/users\/misra\/scannedPdf.dir\/FindRepeatedElements.pdf\">\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d<\/a> \u0432 1982 \u0430\u043c\u0435\u0440\u0438\u043a\u0430\u043d\u0441\u043a\u0438\u043c\u0438 \u0443\u0447\u0451\u043d\u044b\u043c\u0438 \u0414\u0436\u0430\u044f\u0434\u0435\u0432\u043e\u043c \u041c\u0438\u0441\u0440\u043e\u0439 \u0438 \u0414\u044d\u0432\u0438\u0434\u043e\u043c \u0413\u0440\u0438\u0441\u043e\u043c (Jayadev Misra &#038; David Gries), \u0438 \u0432 \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043a\u0443\u0447\u043d\u0430\u044f \u043c\u0435\u0442\u0430\u0444\u043e\u0440\u0430 \u2014 \u043c\u0435\u0448\u043e\u043a \u0441 <i>N<\/i> \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043d\u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442 \u043f\u043e 3 \u0440\u0430\u0437\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 \u0437\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u0445 \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434 \u043d\u0435 \u043f\u043e\u0445\u043e\u0436 \u043d\u0438 \u043d\u0430 \u043e\u0434\u0438\u043d \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0443 \u044f\u0437\u044b\u043a. \u041c\u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432 <a href=\"http:\/\/www.cs.dartmouth.edu\/~ac\/Teach\/CS49-Fall11\/Notes\/lecnotes.pdf\">\u043f\u043e\u0437\u0430\u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e\u0434\u043d\u0435\u043c \u043a\u043e\u043d\u0441\u043f\u0435\u043a\u0442\u0435 \u043b\u0435\u043a\u0446\u0438\u0439<\/a> \u0430\u043c\u0435\u0440\u0438\u043a\u0430\u043d\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u043e\u0440\u0430 \u0410\u043c\u0438\u0442\u0430 \u0427\u0430\u043a\u0440\u0430\u0431\u0430\u0440\u0442\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/06c\/527\/4e4\/06c5274e4a647b81b83932a0f1162897.jpg\"\/><\/p>\n<p>  \u0412 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0435\u0439 \u0444\u043e\u0440\u043c\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0434\u043b\u0438\u043d\u043e\u0439 <i>N<\/i> \u043d\u0430\u0434\u043e \u043d\u0430\u0439\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 <i>N<\/i>\/<i>k<\/i> \u0440\u0430\u0437 \u2014 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f-\u0442\u0430\u043a\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u0451\u043c. \u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043b\u044e\u0434\u0438 \u0441\u0442\u043e\u044f\u0442 \u2014 \u0442.\u0435. \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 <i>k<\/i>-1 \u0437\u0430\u043f\u0438\u0441\u0435\u0439.  <\/p>\n<pre><code>int[] majority(int[] array, int N, int k) {   \/\/ \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441\u0442\u043e\u044f\u0449\u0438\u0445 \u043b\u044e\u0434\u0435\u0439 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u0443\u0441\u0442   Dictionary&lt;int,uint&gt; candidates = new Dictionary&lt;int,uint&gt;{};    \/\/ \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0438 \u0443\u0441\u0430\u0436\u0438\u0432\u0430\u0435\u043c \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u043e k   for (int i = 0; i&lt;N; i++) {      \/\/ \u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u0430\u043a \u0443 \u0441\u0442\u043e\u044f\u0449\u0438\u0445? \u0442\u043e\u0433\u0434\u0430 \u0432\u0441\u0442\u0430\u043d\u0435\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438     if (candidates.ContainsKey(array[i]))       candidates[array[i]]++;     else \/\/ \u043c\u043e\u0436\u0435\u0442, \u0441\u0442\u043e\u044f\u0442 \u043c\u0435\u043d\u0435\u0435 \u0447\u0435\u043c \u0441 k-1 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438?       if (candidates.Count &lt; k - 1)         candidates[array[i]] = 1;     else \/\/ \u0441\u0442\u043e\u044f\u0442 \u0441 k-1 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u0443\u0441\u0430\u0436\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u044e \u0433\u0440\u0443\u043f\u043f\u0443       foreach(int l in candidates.Keys)         if (candidates[l]-- == 0)              \/\/ (**)           candidates.Remove(l);                \/\/ (*)   }    return candidates.Keys.ToArray(); } <\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0435\u0439 \u0444\u043e\u0440\u043c\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u2014 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0438 <i>O<\/i>(<i>k<\/i>) \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439, \u0430 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 \u0441\u0432\u044f\u0436\u0435\u043c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u2014 \u0442\u043e\u0433\u0434\u0430 \u043e\u0431\u0449\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439: \u0441\u0442\u0440\u043e\u0447\u043a\u0430 (*) \u0441 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0435 \u0431\u043e\u043b\u044c\u0448\u0435\u0435 <i>N<\/i> \u0440\u0430\u0437, \u0432\u0435\u0434\u044c \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438. \u0427\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0430 (**) \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0441\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u0448\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0441 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0441\u043c\u043e\u0433\u043b\u043e \u0431\u044b \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 <a href=\"http:\/\/habrahabr.ru\/post\/166377\/\">\u043e\u0434\u043d\u0438\u043c \u043f\u0443\u0448\u0438\u0441\u0442\u044b\u043c \u0437\u0432\u0435\u0440\u044c\u043a\u043e\u043c<\/a>, \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0440\u0435\u043f\u0430\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0445\u0430\u0431\u0440\u0430\u0443\u043c\u0435\u043b\u044c\u0446\u0430\u043c\u0438. \u0421\u0438\u0433\u043d\u0430\u043b\u044b \u044d\u0442\u043e\u0433\u043e \u0437\u0432\u0435\u0440\u044c\u043a\u0430 \u0438\u043c\u0435\u044e\u0442 \u043f\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439: \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c <i>k<\/i>=6, \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u043f\u044f\u0442\u044c \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u043f\u0440\u044f\u043c\u043e \u043d\u0430 \u0445\u043e\u0434\u0443, \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c. \u041d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043f\u044f\u0442\u044c \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438\u0441\u044c \u0432 \u0441\u0438\u0433\u043d\u0430\u043b\u0435 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0447\u0430\u0441\u0442\u043e.<\/p>\n<p>  \u0414\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u041c\u0438\u0441\u0440\u044b-\u0413\u0440\u0438\u0441\u0430 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0437\u0430 \u0442\u0440\u0430\u0444\u0438\u043a\u043e\u043c \u0432 \u0441\u0435\u0442\u0438, \u0438 \u0435\u0441\u043b\u0438 \u043d\u0435\u043a\u0438\u0439 \u043e\u0434\u0438\u043d \u0445\u043e\u0441\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 \u043d\u0435\u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u2014 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435. \u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043a\u043b\u0438\u043a\u0430\u043c\u0438 \u043f\u043e \u0431\u0430\u043d\u043d\u0435\u0440\u0430\u043c, \u0437\u0430 \u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u044b\u043c\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u043c\u0438, \u0437\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435\u2026 \u0412 \u043e\u0431\u0449\u0435\u043c, \u0432\u0441\u044e\u0434\u0443, \u0433\u0434\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0439 \u2014 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044f.<\/p>\n<p>  <i>\u0417\u0430 \u043e\u0436\u0438\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u043d\u0430\u0434\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0438\u0442\u044c <a href=\"http:\/\/habrahabr.ru\/users\/nitatunarabe\/\" class=\"user_link\">Nitatunarabe<\/a><\/i>    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/167177\/\"> http:\/\/habrahabr.ru\/post\/167177\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0417\u0430\u0434\u0430\u0447\u0430: \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0434\u043b\u0438\u043d\u043e\u0439 <i>N<\/i> \u043d\u0430\u0439\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 <i>N<\/i>\/2 \u0440\u0430\u0437.<\/p>\n<p>  \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u0447\u0435\u0433\u043e \u0442\u0443\u0442 \u0434\u0443\u043c\u0430\u0442\u044c? \u0412\u043e\u0437\u044c\u043c\u0451\u043c Dictionary&lt;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0439&gt;, \u0437\u0430 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0441\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0438\u0437 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430 <i>O<\/i>(<i>N<\/i>), \u043a\u0443\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0435\u0449\u0451 \u0431\u044b\u0441\u0442\u0440\u0435\u0435?<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/267\/705\/51e\/26770551ed1bc6ca46b744dc85ed0de6.jpg\"\/><br \/>  \u0415\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043d\u044e\u0430\u043d\u0441: \u0434\u043b\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <i>O<\/i>(<i>N<\/i>) \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u2014 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0438 \u044d\u0442\u043e \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0432\u0430\u0440\u044f \u0445\u043e\u0442\u044c \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439, \u0445\u043e\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e\u043c. \u0427\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u043d\u0430\u0448\u0430 \u0446\u0435\u043b\u044c \u2014 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043d\u0435\u043a\u0438\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0441 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e? \u041c\u0430\u0441\u0441\u0438\u0432 \u2014 \u0437\u0430\u043c\u0435\u0440\u044b \u0443\u0440\u043e\u0432\u043d\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u0430, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0434\u0438\u043d \u2014 \u00ab\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439\u00bb \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u2014 \u0448\u0443\u043c \u0438 \u043f\u043e\u043c\u0435\u0445\u0438. \u041d\u0435\u0443\u0436\u0435\u043b\u0438 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u00ab\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e\u00bb \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043e\u0437\u0438\u0442\u044c\u0441\u044f \u0441 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u0438 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u043c\u0438?<\/p>\n<p>  \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043d\u0435\u0442: \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e <i>O<\/i>(1) \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0438 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-167177","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/167177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=167177"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/167177\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=167177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=167177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=167177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}