题目
Programming Programming In-class Test - Part 2 Programming Programming In-class Test - Part 2
多项选择题
A monotonic sequence is a sequence in which is either increasing or decreasing.The following are monotonic:1,1,3,4,4,4 (increasing) 1,2,3,4,5 (increasing) 5,5,3,2,1,1 (decreasing) 5,4,3,2,1 (decreasing) Given a grid of numbers, e.g.,01 02 03 04 05 0301 03 01 01 01 0304 04 05 07 01 0302 02 05 02 02 0301 04 05 01 02 0302 04 03 04 02 01Consider the longest monotonic (increasing or decreasing) sequence within the grid if we consider left-to-right (rows) and top-to-bottom (columns). You should also continue a sequence at the end of a row into the next row. This also applies when looking at the columns. You should start in the top left in both cases.For example the following are possible increasing sequences:01 02 03 04 05 0301 03 01 01 01 0304 04 05 07 01 0302 02 05 02 02 0301 04 05 01 02 0302 04 03 04 02 0101 02 03 04 05 0301 03 01 01 01 0304 04 05 07 01 0302 02 05 02 02 0301 04 05 01 02 0302 04 03 04 02 0101 02 03 04 05 0301 03 01 01 01 0304 04 05 07 01 0302 02 05 02 02 0301 04 05 01 02 0302 04 03 04 02 0101 02 03 04 05 0301 03 01 01 01 0304 04 05 07 01 0302 02 05 02 02 0301 04 05 01 02 0302 04 03 04 02 01The longest monotonic (increasing or decreasing) sequence (given below) in this grid is of length 10.01 02 03 04 05 0301 03 01 01 01 0304 04 05 07 01 0302 02 05 02 02 0301 04 05 01 02 0302 04 03 04 02 01What is the length of the longest monotonic (increasing or decreasing) sequence in the following grid? 789 6793 844 6791 8872 9701 4329 1020 9641 9734 8724 8789 5900 5148 3952 -261 1943 1602 2916 6790 74 7536 8666 6399 -91 906 153 3432 866 7781 2200 6989 1328 -217 7785 6563 2154 3991 7061 56593102 130 4691 2916 1181 9146 659 6359 8488 6445 2310 -456 2193 1552 9811 7012 5476 9534 9080 6850-140 2203 2569 9874 770 2145 9239 6268 4376 4076 7754 1026 7677 1912 -268 3126 2297 5957 4343 23662105 7345 414 1039 2345 7452 862 603 6911 2625 421 4986 7612 6429 7005 7413 9214 7978 6877 80938712 2716 4267 4977 3797 9676 9472 6066 2314 34 3180 6735 6763 3951 606 1610 3330 1113 6 87649089 5609 5369 -41 1533 2993 4513 9457 4276 2929 3942 5203 6292 7393 1876 -88 779 4473 7210 4855850 4833 3530 4633 3253 2064 6371 9066 6184 8243 3943 3699 4373 4883 3746 1580 3343 704 6616 53285802 506 3972 7552 5974 7466 1685 1806 9725 6642 8345 4032 4241 1769 5627 3936 6588 1334 1027 39462658 8902 7121 6457 958 3068 5176 375 2265 6567 4051 2020 627 7747 1426 6677 9534 4890 6137 37135008 8594 4821 3128 7431 5616 2354 5525 5975 2995 8006 2109 7661 8922 2395 3105 8145 4028 9032 23747065 8920 9187 669 8617 -47 5310 1087 1553 4867 5496 3785 5876 3484 144 4514 2335 6241 6959 62765935 6780 4887 6197 8002 4639 7989 6621 6345 5132 4426 9313 9206 7284 9736 -231 2440 8619 3308 96505809 7899 3104 2661 1160 8972 7020 5925 75 6654 5447 6186 9757 722 4555 2658 8233 5331 8991 71738083 -249 7145 438 6469 7430 -292 3598 -442 3032 6572 9959 -356 389 7755 3415 3461 2757 6803 13978252 9081 3916 5309 1856 5990 2373 1468 3709 886 8739 8351 2108 4084 2904 8279 6249 9002 680 45711697 -273 5562 825 5098 -211 1005 5485 9720 3066 8921 9806 171 733 8157 1930 5699 7428 8667 85409778 5059 3558 7506 6381 4497 5588 6185 5669 5826 6124 9269 -474 5078 8724 6120 -340 3923 1891 17626959 8160 635 8369 3707 1103 5297 5445 8312 3390 5822 3610 8580 9152 9821 7821 8232 8262 771 8215 9 9950 5294 8343 9046 4272 -184 8719 1854 -441 9477 3233 -100 3657 6278 4552 4001 2954 4703 83To get you started the numbers are provided as a list of lists.grid = [[789,6793,844,6791,8872,9701,4329,1020,9641,9734,8724,8789,5900,5148,3952,-261,1943,1602,2916,6790],[74,7536,8666,6399,-91,906,153,3432,866,7781,2200,6989,1328,-217,7785,6563,2154,3991,7061,5659],[3102,130,4691,2916,1181,9146,659,6359,8488,6445,2310,-456,2193,1552,9811,7012,5476,9534,9080,6850],[-140,2203,2569,9874,770,2145,9239,6268,4376,4076,7754,1026,7677,1912,-268,3126,2297,5957,4343,2366],[2105,7345,414,1039,2345,7452,862,603,6911,2625,421,4986,7612,6429,7005,7413,9214,7978,6877,8093],[8712,2716,4267,4977,3797,9676,9472,6066,2314,34,3180,6735,6763,3951,606,1610,3330,1113, 6,8764],[9089,5609,5369,-41,1533,2993,4513,9457,4276,2929,3942,5203,6292,7393,1876,-88,779,4473,7210,485],[5850,4833,3530,4633,3253,2064,6371,9066,6184,8243,3943,3699,4373,4883,3746,1580,3343,704,6616,5328],[5802,506,3972,7552,5974,7466,1685,1806,9725,6642,8345,4032,4241,1769,5627,3936,6588,1334,1027,3946],[2658,8902,7121,6457,958,3068,5176,375,2265,6567,4051,2020,627,7747,1426,6677,9534,4890,6137,3713],[5008,8594,4821,3128,7431,5616,2354,5525,5975,2995,8006,2109,7661,8922,2395,3105,8145,4028,9032,2374],[7065,8920,9187,669,8617,-47,5310,1087,1553,4867,5496,3785,5876,3484,144,4514,2335,6241,6959,6276],[5935,6780,4887,6197,8002,4639,7989,6621,6345,5132,4426,9313,9206,7284,9736,-231,2440,8619,3308,9650],[5809,7899,3104,2661,1160,8972,7020,5925,75,6654,5447,6186,9757,722,4555,2658,8233,5331,8991,7173],[8083,-249,7145,438,6469,7430,-292,3598,-442,3032,6572,9959,-356,389,7755,3415,3461,2757,6803,1397],[8252,9081,3916,5309,1856,5990,2373,1468,3709,886,8739,8351,2108,4084,2904,8279,6249,9002,680,4571],[1697,-273,5562,825,5098,-211,1005,5485,9720,3066,8921,9806,171,733,8157,1930,5699,7428,8667,8540],[9778,5059,3558,7506,6381,4497,5588,6185,5669,5826,6124,9269,-474,5078,8724,6120,-340,3923,1891,1762],[6959,8160,635,8369,3707,1103,5297,5445,8312,3390,5822,3610,8580,9152,9821,7821,8232,8262,771,8215],[9,9950,5294,8343,9046,4272,-184,8719,1854,-441,9477,3233,-100,3657,6278,4552,4001,2954,4703,83],]You may use the following for this question.Python InterpretersOnline Python Interpreter - online editor (onlinegdb.com) Python Tutor: Learn Python, JavaScript, C, C++, and Java programming by visualizing codeOnline Python Compiler (Interpreter) (programiz.com)Python ResourcesLearn Python Programming (programiz.com) Python Tutorial (w3schools.com)3.11.7 Documentation (python.org)https://www.pythoncheatsheet.org/
选项
A.7
B.4
C.12
D.15
E.8
F.21
G.13
H.17
I.25
J.11
查看解析
标准答案
Please login to view
思路分析
We are asked to determine the length of the longest monotonic (increasing or decreasing) sequence in a large grid, where sequences can wrap from end of a row to the start of the next row, and similarly for columns, starting from the top-left in both row-wise and column-wise traversals. The options present various possible lengths to test understanding.
Option 1: 7
This is the stated correct length in the provided answer key. It implies that, after examining all possible left-to-right row traversals with wrap-around and top-to-bottom column traversals with wrap-around, the maximum achievable monotonic run (in either direction) has length 7.......Login to view full explanation登录即可查看完整答案
我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。
类似问题
In a consumer society, many adults channel creativity into buying things
Economic stress and unpredictable times have resulted in a booming industry for self-help products
People born without creativity never can develop it
A product has a selling price of $20, a contribution margin ratio of 40% and fixed cost of $120,000. To make a profit of $30,000. The number of units that must be sold is: Type the number without $ and a comma. Eg: 20000
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!