Cody

# Problem 45473. Sub-sequence - 01

Solution 3650993

Submitted on 13 Nov 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
x =[2,4,2,1,3,5,6]; assert(isequal(longest_sub_2(x),4))

y = 2 yy = 2

Assertion failed.

2   Fail
x=[15,27,14,38,26,55,46,65,85]; assert(isequal(longest_sub_2(x),6))

y = 2 2 2 yy = 2

Assertion failed.

3   Fail
x =[2,4,2,1,3,5,6,12,0,2,1,1,2,1,4,5,6,12,3,2]; assert(isequal(longest_sub_2(x),7))

y = 2 5 yy = 5

Assertion failed.

4   Fail
x =[82 91 13 92 64 10 28 55 96 97 16 98 96 49 81 15 43 92 80 96 66 4 85 94 68]; assert(isequal(longest_sub_2(x),6))

y = 2 2 1 5 2 2 3 1 3 yy = 5

Assertion failed.

5   Fail
x =[758 744 393 656 172 707 32 277 47 98 824 695 318 951 35 439 382 766 796 187 490 446 647 710 755 277 680 656 163 119 499 960 341 586 224 752 256 506 700 891 960 548 139 150 258 841 255 815 244 930]; assert(isequal(longest_sub_2(x),11))

y = 1 1 2 2 2 3 1 2 2 3 2 4 1 1 3 2 2 4 1 4 2 yy = 4

Assertion failed.

6   Fail
x =ones(1,1000); assert(isequal(longest_sub_2(x),1))

y = [] yy = []

Assertion failed.

7   Fail
x =[ones(1,1000),zeros(1,50),2*ones(1,20)]; assert(isequal(longest_sub_2(x),2))

y = 1 yy = 1

Assertion failed.

8   Fail
x=[34999 19660 25109 61605 47329 35166 83083 58527 54973 91720 28584 75721 75373 38045 56783 7586 5396 53080 77917 93402 12991 56883 46940 1191 33713 16219 79429 31122 52854 16565 60199 26298 65408 68922 74816 45055 8383 22898 91334 15238 82582 53835 99614 7818 44268 10666 96190 464 77492 81731 86870 8444 39979 25988 80007 43142 91065 18185 26381 14554 13607 86930 57971 54987 14496 85304 62206 35096 51325 40181 7597 23992 12332 18391 23996 41727 4966 90272 94479 49087 48926 33772 90006 36925 11121 78026 38974 24170 40392 9646 13198 94206 95614 57521 5978 23478 35316 82120 1541 4303 16900 64912 73173 64775 45093 54701 29633 74470 18896 68678 18352 36849 62562 78023 8113 92939 77572 48680 43586 44679 30635 50851 51078 81763 79484 64432 37861 81159 53283 35073 93901 87595 55016 62248 58705 20775 30125 47093 23049 84431 19477 22593 17071 22767 43570 31111 92338 43021 18482 90489 97975 43887 11112 25807 40872 59490 26222 60285 71122 22175 11742 29668 31878 42417 50786 8552 26249 80102 2923 92886 73034 48861 57853 23729 45885 96309 54681 52114 23160 48890 62407 67914 39552 36744 98799 3774 88517 91329 79619 9872 26188 33536 67973 13656 72123 10677 65376 49418 77906 71504 90373 89093 33417 69875 19781 3055 74408 50003 47993 90473 60987 61767 85945 80549 57673 18293 23994 88652 2868 48991 16793 97869 71270 50048 47109 5962 68198 4244 7145 52165 9674 81815 81755 72244 14987 65961 51860 97298 64900 80034 45380 43240 82532 8347 13318 17339 39094 83138 80337 6048 39926 52688 41680 65686 62798 29199 43166 1549 98407 16717 10622 37241 19812 48969 33950 95164 92034 5268 73786 26912 42284 54788 94274 41775 98306 30146 70110 66634 53913 69811 66653 17814 12802 99909 17113 3261 56120 88187 66918 19044 36892 46073 98164 15641 85553 64477 37628 19093 42826 48203 12062 58951 22619 38462 58299 25181 29045 61710 26529 82438 98267 73025 34388 58407 10777 90631 87966 81777 26073 59436 2252 42526 31272 16149 17877 42289 9423 59853 47093 69595 69989 63854 3361 6881 31960 53087 65445 40762 81999 71836 96865 53134 32515 10563 61096 77881 42346 9083 26648 15366 28101 44009 52715 45743 87538 51806 94363 63771 95770 24071 67613 28907 67181 69515 6800 25480 22405 66784 84440 34447 78052 67534 672 60218 38678 91600 116 46245 42435 46092 77016 32248 78474 47136 3577 17588 72176 47349 15273 34113 60739 19175 73843 24285 91743 26907 76551 18867 28750 9112 57621 68337 54660 42573 64445 64762 67902 63579 94518 20894 70929 23624 11940 60731 45014 45873 66195 77029 35022 66201 41616 84193 83292 25645 61347 58225 54074 86995 26478 31808 11922 93983 64556 47947 63932 54472 64732 54389 72105 52250 99371 21868 10580 10970 6360 40458 44838 36582 76351 62790 77199 93286 97275 19203 13888 69627 9383 52541 53035 86114 48486 39346 67144 74126 52006 34772 15000 58610 26215 4446 75494 24279 44241 68780 35923 73635 39471 68342 70405 44231 1958 33086 42431 27028 19706 82173 42993 88778 39119 76912 39680 80852 75508 37740 21602 79041 94931 32757 67127 43865 83351 76886 16726 86199 98988 51443 88429 58803 15476 19987 40696 74871 82559 78997 31853 53407 8996 11171 13630 67866 49518 18972 49501 14761 5498 85072 56056 92961 69667 58280 81540 87902 98892 53 86544 61257 98996 52769 47953 80135 22785 49810 90086 57467 84518 73865 58599 24674 66642 8349 62596 66095 72976 89076 98231 76903 58145 92832 58010 1699 12086 86272 48430 84486 20941 55230 62989 3200 61472 36242 4954 48957 19252 12309 20550 14652 18908 4266 63520 28187 53860 69517 49912 53581 44519 12394 49036 85300 87393 27030 20847 56498 64032 41703 20598 94794 8208 10571 14205 16647 62096 57371 5208 93121 72867 73785 6341 86045 93441 98440 85894 78556 51338 17761 39859 13394 3089 93915 30131 29554 33294 46707 64820 2523 84221 55904 85410 34788 44603 5424 17711 66281 33083 89849 11816 98842 53999 70692 99950 28785 41453 46484 76396 81821 10023 17812 35964 5671 52189 33585 17567 20895 90516 67540 46847 91214 10402 74555 73627 56187 18420 59722 29994 13413 21261 89495 7146 24249 5376 44173 1329 89720 19666 9338 30737 45606 10167 99539 33210 29735 6205 29825 4636 50543 76143 63107 8990 8087 77725 90514 53378 10916 82581 33810 29398 74632 1034 4845 66792 60347 52611 72971 70726 78138 28798 69254 55667 39653 6160 78018 33759 60787 74126 10482 12789 54955 48523 89048 79897 73435 5134 7289 8853 79836 94301 68372 13209 72273 11036 11750 64072 32882 65382 74914 58319 74004 23483 73496 97060 86694 8624 36644 36920 68503 59795 78937 36766 20603 8667 77194 20568 38828 55178 22896 64195 48449 15185 78194 10061 29407 23738 53088 9150 40532 10485 11229 78443 29158 60354 96443 43249 69476 75810 43265 65550 10976 93376 18747 26618 79784 48761 76896 39601 27294 3724 67330 42957 45174 60986 5941 31582 77273 69644 12534 13016 9236 783 42311 65558 72293 53121 10882 63177 12650 13431 9860 14203 16826 19625 31748 31643 21757 25105 89293 70323 55574 18444 21204 7735 91381 70672 55779 31343 16621 62250 98794 17044 25780 39680 7400 68410 40239 98284 40219 62068 15437 38135 16114 75812 87112 35078 68554 29415 53063 83243 59750 33532 29923 45260 42265 35961 55832 74255 42434 42936 12488 2444 29019 31753 65370 95694 93574 45789 24048 76390 75933 74065 74369 10593 68157 46327 21217 9852 82358 17501 16357 66599 89439 51656 70271 15360 95346 54089 67974 3657 80921 74862 12019 52505 32584 54645 39889 41510 18074 25539 2054 92368 65370 93262 16352 92110 79466 57740 44004 25762 75195 22867 6419 76733 67121 71522 64207 41905 39077 81615 31743 81454 78908 85227 50564 63567 95090 44397 6002 86675 63119 35508 99701 22418 65246 60500 38725 14219 2514 42112 18411 72578 37037 84157 73423 57103 17686 95739 26533 92459 22378 37357 8751 64012 18062 4506 72318 34744 66062 38387 62735 2165 91057 80056 74585 81312 38331 61728 57550 53006 27507 24863 45164 22772 80445 98611 3000 53567 8708 80210 98915 6695 93940 1818 68384 78374 53414 88536 89901 62594 13787 21781 18215 4182 10695 61645 93967 35446 41063 98435 94558 67665 98831 76684 33670 66239 24417 29551 68018 52785 41160 60264 75053 58354 55180 58358 51182 8260 71958 99616 35454 97126 34645 88655 45470 41343 21774 12566 30892 72611 78288 69379 981 84322 92234 77096 4266 37819 70434 72952 22428 26906 67304 47750 62372 23645 17713 82965 76693 93448 10789 18223 9910 48977 19325 89590 9909 4417 55730 77250 31195 17899 33896 21015 51016 90637 62893 10154 39086 5462 50129 43173 99757 81161 48566 89445 13755 39001 92736 91750 71358 61834 34329 93603 12478 73059 64648 83316 39829 74983 83523 32247 55227 97913 54931 33043 61948 36064 75651 41391 49235 69475 97274 32776 83781 73908 95418 3193 35687 66266 28151 23039 71113 62458 59061 66044 4756 34879 45135 24091 71505 85619 28151 73106 13777 83673 13861 58821 36616 80676 50379 48960 87705 35315 44945 96354 4230 97296 18921 66713 58644 67512 36103 62028 81116 1926 8388 97481 65135 23124 40350 12203 26844 25785 33167 15224 34801 12166 88416 9428 93005 39902 4741 34238 73597 79469 54491 68623 89364 5480 30367 4620 19548 72017 72176 87780 58244 7069 92275 80038 28595 54367 98478 71568 83897 43327 47063 56072 26910 74902 50389 64681 30775 13873 47558 36246 78812 78030 66852 13351 2156 55985 30082 93941 98091 28663 80083 89612 59753 88402 94374 54916 72839 57676 2586 44654 64631 52121 37232 93714 82954 84909 37254 59319 87256 93351 66847 20678 65386 7206 40673 66694 93373 81096 48455 75675 41705 97179 98798 86415 38889 45475 24669 78443 88284 91372 55829 59887 14888 89972 45040 20568 89966 76259 88249 28496 67323 66428 12282 40732 27529 71667 28339 89620 82658 39003 49791 69481 83437 60963 57474 32605 45643 71380 88441 72086 1862 67478 43851 43783 11704 81469 32486 24623 34272 37570 54656 56193 39583 39814 51537 65754 95092 72235 40008 83188 13434 6047 8425 16390 32422 30173 1169 53991 9538 14652 63115 85933 97423 57084 99686 55355 51546 33069 43001 49181 7104 88774 6464 43619 82663 39454 61348 81865 88624 93112 19079 25859 89787 59337 50385 61281 81943 53189 20208 45390 42792 96606 62006 69539 72017 34690 51700 55670 15650 56206 69481 42646 83628 73139 36004 45422 38639 77556 73428 43028 69376 94522 78424 70558 10934 38994 59091 45939 5034 22869 83419 1565 86372 7807 66905 50022 21800 57162 12219 67117 59959 5598 5635 15251 1963 43518 83223 61740 52013 86387 9770 90806 10802 51700 14316 55938 458 76669 84871 91683 98697 50514 27143 10076 50785 58561 76289 8297 66160 51698 17105 93856 59049 44064 94192 65592 45195 83970 53263 55389 68007 36719 23930 57893 86689 40678 11262 44385 30019 40139 83337 40363 39018 36045 14026 26014 8682 42940 25729 29756 42486 11921 49507 70641 24358 78508 7409 39389 340 22068 131 18918 14249 26808 17490 13865 59889 90106 93938 22119 48268 37602 52379 26488 6836 43633 17386 2611 95468 43060 96156 76242 735 68004 70596 64513 55231 21811 77237 22803 37087 89093 85638 40244 31802 60864 91020 90910 59160 33258 85307 44240 90436 3318 53243 71650 17931 33654 18772 32193 40386 54857 4874 55274 27482 24151 24315 15416 95642]; assert(isequal(longest_sub_2(x),72))

y = Columns 1 through 29 1 3 1 2 1 2 2 1 2 1 4 2 1 2 2 2 2 4 1 3 2 2 2 2 4 2 2 2 2 Columns 30 through 58 1 2 1 1 2 1 2 1 2 4 3 1 1 2 1 2 1 2 4 1 4 5 1 2 2 2 4 2 1 Columns 59 through 87 1 2 4 1 1 2 1 2 1 2 1 3 2 2 3 2 1 3 1 4 3 1 5 3 2 1 2 3 1 Columns 88 through 116 1 4 1 2 3 1 4 2 2 2 2 1 2 1 2 1 2 3 1 1 3 2 2 1 1 1 2 3 2 Columns 117 through 145 1 1 2 2 2 1 2 5 1 3 2 1 2 2 1 2 2 2 1 2 4 2 2 1 2 1 1 2 1 Columns 146 through 174 3 1 4 2 1 1 3 2 3 3 3 1 2 2 1 1 2 2 1 3 4 1 5 2 2 1 1 3 1 Columns 175 through 203 2 4 2 2 2 2 3 2 3 2 1 2 2 2 3 2 1 3 1 3 2 2 2 2 3 1 4 2 2 Columns 204 through 232 1 2 4 2 2 1 2 1 2 2 2 1 2 2 2 2 1 2 3 2 4 1 2 4 1 3 1 1 2 Columns 233 through 261 1 2 3 2 3 1 3 1 2 2 2 2 1 1 3 2 2 1 3 2 1 5 1 2 4 1 2 1 2 Columns 262 through 290 2 1 4 2 2 1 2 3 2 1 1 2 6 1 2 1 3 2 3 2 1 2 1 2 2 2 3 2 1 Columns 291 through 319 4 1 3 1 2 5 1 2 2 4 1 1 1 2 1 2 1 4 2 2 2 3 2 2 3 5 3 2 1 Columns 320 through 348 3 1 2 2 1 1 2 1 3 2 2 2 1 3 2 1 1 2 3 1 1 3 1 2 1 2 3 1 2 Columns 349 through 377 2 2 1 1 2 2 3 2 1 1 5 1 2 3 3 2 3 1 4 2 1 1 2 3 2 1 2 2 2 Columns 378 through 406 2 3 3 3 2 2 3 2 1 1 2 3 3 1 2 1 4 1 2 2 5 1 3 1 1 2 2 1 1 Columns 407 through 435 1 3 2 2 2 2 2 3 2 3 1 1 2 1 3 2 1 5 1 1 2 1 2 2 1 1 2 1 3 Columns 436 through 464 2 2 2 2 1 2 2 2 2 3 2 1 1 1 2 1 2 2 1 1 2 2 2 3 1 2 1 2 2 Columns 465 through 493 1 1 1 2 2 2 1 1 2 2 2 2 1 2 2 2 2 1 2 2 1 1 1 2 3 2 3 2 3 Columns 494 through 522 3 1 2 1 4 3 1 2 1 2 3 1 3 1 2 1 3 2 2 1 1 1 4 1 3 1 3 3 2 Columns 523 through 551 1 2 2 2 2 2 1 3 1 2 3 1 2 2 2 1 2 3 1 1 1 2 2 2 3 3 1 2 2 Columns 552 through 580 4 2 2 3 1 2 1 2 3 3 1 2 2 2 1 2 3 2 2 2 3 3 1 2 2 2 2 2 2 Columns 581 through 609 1 4 3 2 4 1 2 1 3 2 3 2 2 1 2 2 1 1 1 2 3 3 3 2 1 3 1 2 2 Columns 610 through 638 4 1 2 4 1 2 3 1 2 3 2 2 2 2 2 1 2 2 2 1 4 1 1 4 1 2 1 1 2 Columns 639 through 667 1 5 5 1 2 1 4 1 2 4 2 1 1 3 2 3 5 3 1 3 1 2 2 2 3 2 2 1 2 Columns 668 through 696 2 1 3 1 1 3 1 3 2 2 1 2 2 1 3 3 1 2 2 3 5 1 1 4 2 1 2 1 2 Columns 697 through 725 1 2 3 1 3 1 2 3 1 1 1 2 2 3 3 2 2 2 2 2 1 4 2 2 1 2 1 2 2 Columns 726 through 743 1 3 1 1 2 3 1 3 1 1 2 2 3 2 4 2 1 2 yy = 6

Assertion failed.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!