{"id":300975,"date":"2020-03-30T15:00:36","date_gmt":"2020-03-30T15:00:36","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=300975"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=300975","title":{"rendered":"\u0412\u044b\u043f\u0443\u0441\u043a#34: IT\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043a\u0430 \u2014 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0442 \u0432\u0435\u0434\u0443\u0449\u0438\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/spice\/blog\/494310\/\">\u041f\u0440\u0438\u0432\u0435\u0442! \u041c\u044b \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u0412\u0430\u043c \u043f\u043e\u0434\u0431\u043e\u0440\u043a\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0437\u0430\u0434\u0430\u0447\u0435\u043a \u0441 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0432 \u0432\u0435\u0434\u0443\u0449\u0438\u0435 IT-\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438! <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gb\/xj\/ul\/gbxjuldvtuid-ptlc_qift9a6he.png\"><\/p>\n<p>  \u0412\u044b\u043f\u0443\u0441\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u2014 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438! \u0420\u0443\u0431\u0440\u0438\u043a\u0430 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u0440\u0435\u043a\u0440\u0443\u0442\u0438\u043d\u0433\u043e\u0432\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0441\u0442\u0432\u0430 <a href=\"http:\/\/www.spice-agency.ru\/ru\/\">Spice IT<\/a>.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u043c\u044b \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0432 \u0438\u043d\u0434\u0438\u0439\u0441\u043a\u0443\u044e \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e Snapdeal. \u041a\u0441\u0442\u0430\u0442\u0438, \u043e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u043a\u0438 \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0432\u044b\u043f\u0443\u0441\u043a\u0430 \u0443\u0436\u0435 <a href=\"https:\/\/habr.com\/ru\/company\/spice\/blog\/494054\/\">\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u044b<\/a>.<a name=\"habracut\"><\/a><\/p>\n<h2>\u0412\u043e\u043f\u0440\u043e\u0441\u044b<\/h2>\n<p>  1. <b>Car Wheel Puzzle<\/b>  <\/p>\n<blockquote><p>A car has 4 tyres and 1 spare tyre. Each tyre can travel a maximum distance of 20000 miles before wearing off. What is the maximum distance the car can travel before you are forced to buy a new tyre? You are allowed to change tyres (using the spare tyre) an unlimited number of times.<\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0435\u0440\u0435\u0432\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\u0410\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c \u0438\u043c\u0435\u0435\u0442 4 \u0448\u0438\u043d\u044b \u0438 1 \u0437\u0430\u043f\u0430\u0441\u043d\u0443\u044e \u0448\u0438\u043d\u0443. \u041a\u0430\u0436\u0434\u0430\u044f \u0448\u0438\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0439\u0442\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 20000 \u043c\u0438\u043b\u044c, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u0438\u0439\u0442\u0438 \u0432 \u043d\u0435\u0433\u043e\u0434\u043d\u043e\u0441\u0442\u044c. \u041a\u0430\u043a\u043e\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0435\u0445\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u043a\u0443\u043f\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0448\u0438\u043d\u0443? \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043c\u0435\u043d\u044f\u0442\u044c \u0448\u0438\u043d\u044b (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u0430\u043f\u0430\u0441\u043d\u0443\u044e \u0448\u0438\u043d\u0443) \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437.<\/div>\n<\/div>\n<p>  2. <b>Completion of Task<\/b>  <\/p>\n<blockquote><p>A man is allocated a task. He doubles the task done everyday. If the man completely does the task in 18 days, how many days did it take for the man to complete 25% of the task?<\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0435\u0440\u0435\u0432\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\u0427\u0435\u043b\u043e\u0432\u0435\u043a\u0443 \u0434\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u0435. \u041a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u043e\u043d \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0432\u0434\u0432\u043e\u0435. \u0415\u0441\u043b\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0437\u0430 18 \u0434\u043d\u0435\u0439, \u0442\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439 \u0435\u043c\u0443 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c 25% \u0437\u0430\u0434\u0430\u043d\u0438\u044f?<\/div>\n<\/div>\n<p>  <\/p>\n<h2>\u0417\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>  1. <b>Next greater number set digits<\/b>  <\/p>\n<blockquote><p>Given a number n, find the smallest number that has same set of digits as n and is greater than n. If n is the greatest possible number with its set of digits, then print \u201cnot possible\u201d.<\/p>\n<p>  <b>Input:<\/b><br \/>  The first line of input contains an integer T denoting the number of test cases.<br \/>  The first line of each test case is n,n is the number.<\/p>\n<p>  <b>Output:<\/b><br \/>  Print the greater number than n with same set of digits and if not possible then print \u00abnot possible\u00bb without double quote.<\/p>\n<p>  <b>Constraints:<\/b><br \/>  <code>1 \u2264 T \u2264 100<br \/>  1 \u2264 n \u2264 100000<\/code><\/p>\n<p>  <b>Example:<br \/>  Input<\/b><br \/>  <code>2<br \/>  143<br \/>  431<\/code><\/p>\n<p>  <b>Output<\/b><br \/>  <code>314<br \/>  not possible<\/code><\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0435\u0440\u0435\u0432\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u0430\u043d\u043e \u0447\u0438\u0441\u043b\u043e n, \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u0442 \u0436\u0435 \u043d\u0430\u0431\u043e\u0440 \u0446\u0438\u0444\u0440, \u0447\u0442\u043e \u0438 n, \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 n. \u0415\u0441\u043b\u0438 n \u2014 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441 \u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0446\u0438\u0444\u0440, \u0442\u043e \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u201cnot possible\u201d.<\/p>\n<p>  <b>\u0412\u0432\u043e\u0434:<\/b><br \/>  \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e T, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432.<br \/>  \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u2014 n. n \u2014 \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e.<\/p>\n<p>  <b>\u0412\u044b\u0432\u043e\u0434:<\/b><br \/>  \u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e, \u0447\u0435\u043c n, \u0441 \u0442\u0435\u043c \u0436\u0435 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0446\u0438\u0444\u0440, \u0438 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0442\u043e \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u00abnot possible\u00bb.<\/p>\n<p>  <b>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f:<\/b><br \/>  <code>1 \u2264 T \u2264 100<br \/>  1 \u2264 n \u2264 100000<\/code><\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440:<br \/>  \u0412\u0432\u043e\u0434<\/b><br \/>  <code>2<br \/>  143<br \/>  431<\/code><\/p>\n<p>  <b>\u0412\u044b\u0432\u043e\u0434<\/b><br \/>  <code>314<br \/>  not possible<\/code><\/div>\n<\/div>\n<p>  2. <b>Coin Change<\/b>  <\/p>\n<blockquote><p>Given a value N, find the number of ways to make change for N cents, if we have infinite supply of each of S = { S1, S2,\u2026, Sm} valued coins. The order of coins doesn\u2019t matter. For example, for N = 4 and S = {1,2,3}, there are four solutions: {1,1,1,1},{1,1,2},{2,2},{1,3}. So output should be 4. For N = 10 and S = {2, 5, 3, 6}, there are five solutions: {2,2,2,2,2}, {2,2,3,3}, {2,2,6}, {2,3,5} and {5,5}. So the output should be 5.<\/p>\n<p>  <b>Input:<\/b><br \/>  The first line contains an integer &#8216;T&#8217; denoting the total number of test cases. In each test cases, the first line contains an integer &#8216;M&#8217; denoting the size of array. The second line contains M space-separated integers A1, A2, &#8230;, AN denoting the elements of the array. The third line contains an integer &#8216;N&#8217; denoting the cents.<\/p>\n<p>  <b>Output:<\/b><br \/>  Print number of possible ways to make change for N cents.<\/p>\n<p>  <b>Constraints:<\/b><br \/>  <code>1 \u2264 T \u2264 50<br \/>  1 \u2264 N \u2264 300<br \/>  1 \u2264 A[i] \u2264 300<\/code><\/p>\n<p>  <b>Example:<br \/>  Input:<\/b><br \/>  <code>2<br \/>  3<br \/>  1 2 3<br \/>  4<br \/>  4<br \/>  2 5 3 6<br \/>  10<\/code><\/p>\n<p>  <b>Output:<\/b><br \/>  <code>4<br \/>  5<\/code><\/p>\n<p>  <b>Explanation:<\/b><br \/>  <b>Testcase 1:<\/b> The possiblities are as such: {1, 1, 1, 1}, {1, 1, 2}, {1, 3}, {2, 2}.<\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0435\u0440\u0435\u0432\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u0430\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 N, \u043d\u0430\u0439\u0434\u0438\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0430\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u043e\u043d\u0435\u0442\u0443 N, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u043e\u043d\u0435\u0442\u044b \u0442\u0430\u043a\u0438\u0445 \u043d\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0432 S = { S1, S2, &#8230;,., Sm}. \u041f\u043e\u0440\u044f\u0434\u043e\u043a \u043c\u043e\u043d\u0435\u0442 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f N = 4 \u0438 S = {1,2,3} \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0447\u0435\u0442\u044b\u0440\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f: {1,1,1,1},{1,1,2},{2,2},{1,3}. \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043d\u0443\u0436\u043d\u043e 4. \u0414\u043b\u044f N = 10 \u0438 S = {2, 5, 3, 6}, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u044f\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0439: {2,2,2,2,2}, {2,2,3,3}, {2,2,6}, {2,3,5} \u0438 {5,5}. \u0422\u0430\u043a \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043d\u0443\u0436\u043d\u043e 5.<\/p>\n<p>  <b>\u0412\u0432\u043e\u0434:<\/b><br \/>  \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e &#8216;T&#8217;, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0442\u0435\u0441\u0442\u0435 \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e &#8216;M&#8217;, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0412\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 M \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u0435\u043b\u0430\u043c\u0438 A1, A2,&#8230;, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0422\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e &#8216;N&#8217;, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u0441\u0443\u043c\u043c\u0443.<\/p>\n<p>  <b>\u0412\u044b\u0432\u043e\u0434:<\/b><br \/>  \u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0430\u0437\u043c\u0435\u043d\u0430 \u0441\u0443\u043c\u043c\u044b N.<\/p>\n<p>  <b>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f:<\/b><br \/>  <code>1 \u2264 T \u2264 50<br \/>  1 \u2264 N \u2264 300<br \/>  1 \u2264 A [i] \u2264 300<\/code><\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440:<br \/>  \u0412\u0432\u043e\u0434:<\/b><br \/>  <code>2<br \/>  3<br \/>  1 2 3<br \/>  4<br \/>  4<br \/>  2 5 3 6<br \/>  10<\/code><\/p>\n<p>  <b>\u0412\u044b\u0432\u043e\u0434:<\/b><br \/>  <code>4<br \/>  5<\/code><\/p>\n<p>  <b>\u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435:<\/b><br \/>  <b>\u0422\u0435\u0441\u0442 1:<\/b> \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u043e\u0432\u044b: {1, 1, 1, 1}, {1, 1, 2}, {1, 3}, {2, 2}.<\/div>\n<\/div>\n<p>  3. <b>Phone directory<\/b>  <\/p>\n<blockquote><p>Given a list of contacts which exist in a phone directory and a query string str. The task is to implement search query for the phone directory. Run a search query for each prefix p of the query string str(i.e from index 1 to str length) that prints all the distinct recommended contacts which have the same prefix as our query (p) in lexicographical order. Please refer the explanation part for better understanding.<\/p>\n<p>  <b>NOTE:<\/b> If there is no match between query and contacts, print \u00ab0\u00bb.<\/p>\n<p>  <b>Input:<\/b><br \/>  The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains three lines. First line of each test case contains N i.e., number of contacts. Second line contains space separated all the contacts in the form of string. And third line contains query string.<\/p>\n<p>  <b>Output:<\/b><br \/>  For each test case, print each query result in new line. If there is no match between query and contacts, print \u00ab0\u00bb.<\/p>\n<p>  <b>Constraints:<\/b><br \/>  <code>1&lt;=T&lt;=100<br \/>  1&lt;=N&lt;=50<br \/>  1&lt;=|contact[i].length|&lt;=50<br \/>  1&lt;=|query length|&lt;=6<\/code><\/p>\n<p>  <b>Example:<br \/>  Input:<\/b><br \/>  <code>1<br \/>  3<br \/>  spiceit spcicecite spiiceti<br \/>  spicpt<\/code><\/p>\n<p>  Output:<br \/>  <code>spiceit spcicecite spiiceti<br \/>  spiceit spcicecite spiiceti<br \/>  spiceit spiiceti<br \/>  spiceit<br \/>  0<br \/>  0<\/code><\/p>\n<p>  <b>Explanation:<\/b><br \/>  By running the query on contact list, we get, <br \/>  Suggestions based on &quot;<b>s<\/b>&quot; are: <br \/>  <code><b>s<\/b>piceit <b>s<\/b>pcicecite <b>s<\/b>piiceti<\/code><br \/>  Suggestions based on &quot;<b>sp<\/b>&quot; are:<br \/>  <code><b>sp<\/b>iceit <b>sp<\/b>cicecite <b>sp<\/b>iiceti<\/code><br \/>  Suggestions based on &quot;<b>spi<\/b>&quot; are:<br \/>  <code><b>spi<\/b>ceit <b>spi<\/b>iceti<\/code><br \/>  Suggestions based on &quot;<b>spic<\/b>&quot; are:<br \/>  <code><b>spic<\/b>eit<\/code><br \/>  No Results Found for \u00abspicp\u00bb, So print \u00ab0\u00bb.<br \/>  No Results Found for \u00abspicpt\u00bb, So print \u00ab0\u00bb.<\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0435\u0440\u0435\u0432\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u0430\u043d \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u043e\u043c \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0435 \u0438 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 <b>str<\/b>. \u0417\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430. \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 <b>p <\/b>\u0441\u0442\u0440\u043e\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 <b>str <\/b>(\u0442. \u0435. \u043e\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 1 \u0434\u043e \u0434\u043b\u0438\u043d\u044b <b>str<\/b>), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0432\u0441\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u044b\u0435 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u044b, \u0438\u043c\u0435\u044e\u0449\u0438\u0435 \u0442\u043e\u0442 \u0436\u0435 \u043f\u0440\u0435\u0444\u0438\u043a\u0441, \u0447\u0442\u043e \u0438 \u043d\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441 <b>(p)<\/b> \u0432 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435\u0441\u044c \u043a \u043f\u043e\u044f\u0441\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/b> \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u044b \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u00ab0\u00bb.<\/p>\n<p>  <b>\u0412\u0432\u043e\u0434:<\/b><br \/>  \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e T, \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0441\u0442\u043e\u0432. \u0417\u0430\u0442\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0442 T \u0442\u0435\u0441\u0442\u043e\u0432. \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u043a\u0438. \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 N, \u0442. \u0435. \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432. \u0412\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0440\u043e\u0431\u0435\u043b, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u0441\u0435 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u044b \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0410 \u0442\u0440\u0435\u0442\u044c\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>  <b>\u0412\u044b\u0432\u043e\u0434:<\/b><br \/>  \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u043d\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435. \u0415\u0441\u043b\u0438 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u0438 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430\u043c\u0438 \u043d\u0435\u0442 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f, \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u00ab0\u00bb.<\/p>\n<p>  <b>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f:<\/b><br \/>  <code>1&lt;=T&lt;=100<br \/>  1&lt;=N&lt;=50<br \/>  1&lt;=|contact[i].length|&lt;=50<br \/>  1&lt;=|\u0434\u043b\u0438\u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430|&lt;=6<\/code><\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440:<br \/>  \u0412\u0432\u043e\u0434:<\/b><br \/>  <code>1<br \/>  3<br \/>  spiceit spcicecite spiiceti<br \/>  spicpt<\/code><\/p>\n<p>  <b>\u0412\u044b\u0432\u043e\u0434:<\/b><br \/>  <code>spiceit spcicecite spiiceti<br \/>  spiceit spcicecite spiiceti<br \/>  spiceit spiiceti<br \/>  spiceit<br \/>  0<br \/>  0<\/code><\/p>\n<p>  \u041e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435:<br \/>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c,<br \/>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0438\u0441\u043a\u0430 &quot;<b>s<\/b>&quot;, \u0442\u0430\u043a\u043e\u0432\u044b:<br \/>  <code><b>s<\/b>piceit <b>s<\/b>pcicecite <b>s<\/b>piiceti<\/code><br \/>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0438\u0441\u043a\u0430 &quot;<b>sp<\/b>&quot;, \u0442\u0430\u043a\u043e\u0432\u044b:<br \/>  <code><b>sp<\/b>iceit <b>sp<\/b>cicecite <b>sp<\/b>iiceti<\/code><br \/>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0438\u0441\u043a\u0430 &quot;<b>spi<\/b>&quot;, \u0442\u0430\u043a\u043e\u0432\u044b:<br \/>  <code><b>spi<\/b>ceit <b>spi<\/b>iceti<\/code><br \/>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0438\u0441\u043a\u0430 &quot;<b>spic<\/b>&quot;, \u0442\u0430\u043a\u043e\u0432\u044b:<br \/>  <code><b>spic<\/b>eit<\/code><br \/>  \u0414\u043b\u044f \u00abspicp\u00bb \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0432\u0435\u043b\u0438 \u00ab0\u00bb.<br \/>  \u0414\u043b\u044f \u00abspicpt\u00bb \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0432\u0435\u043b\u0438 \u00ab0\u00bb.<\/div>\n<\/div>\n<p>  \u041e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u0430\u043d\u044b \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0438 \u2014 \u0443\u0441\u043f\u0435\u0439\u0442\u0435 \u0440\u0435\u0448\u0438\u0442\u044c. \u0423\u0434\u0430\u0447\u0438!<\/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=\"https:\/\/habr.com\/ru\/company\/spice\/blog\/494310\/\"> https:\/\/habr.com\/ru\/company\/spice\/blog\/494310\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/spice\/blog\/494310\/\">\u041f\u0440\u0438\u0432\u0435\u0442! \u041c\u044b \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u0412\u0430\u043c \u043f\u043e\u0434\u0431\u043e\u0440\u043a\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0437\u0430\u0434\u0430\u0447\u0435\u043a \u0441 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0432 \u0432\u0435\u0434\u0443\u0449\u0438\u0435 IT-\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438! <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gb\/xj\/ul\/gbxjuldvtuid-ptlc_qift9a6he.png\"><\/p>\n<p>  \u0412\u044b\u043f\u0443\u0441\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u2014 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438! \u0420\u0443\u0431\u0440\u0438\u043a\u0430 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u0440\u0435\u043a\u0440\u0443\u0442\u0438\u043d\u0433\u043e\u0432\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0441\u0442\u0432\u0430 <a href=\"http:\/\/www.spice-agency.ru\/ru\/\">Spice IT<\/a>.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u043c\u044b \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0432 \u0438\u043d\u0434\u0438\u0439\u0441\u043a\u0443\u044e \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e Snapdeal. \u041a\u0441\u0442\u0430\u0442\u0438, \u043e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u043a\u0438 \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0432\u044b\u043f\u0443\u0441\u043a\u0430 \u0443\u0436\u0435 <a href=\"https:\/\/habr.com\/ru\/company\/spice\/blog\/494054\/\">\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u044b<\/a>.<\/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-300975","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/300975","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=300975"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/300975\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=300975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=300975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=300975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}