├── .cargo └── config.toml ├── .github ├── FUNDING.yml └── workflows │ └── test.yml ├── .gitignore ├── .gitmodules ├── .rustfmt.toml ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── Makefile.toml ├── README.md ├── adventofcode ├── Cargo.toml ├── desc │ ├── year2015 │ │ ├── day1.md │ │ ├── day10.md │ │ ├── day11.md │ │ ├── day12.md │ │ ├── day2.md │ │ ├── day3.md │ │ ├── day4.md │ │ ├── day5.md │ │ ├── day6.md │ │ ├── day7.md │ │ ├── day8.md │ │ └── day9.md │ └── year2020 │ │ ├── day1.md │ │ ├── day10.md │ │ ├── day11.md │ │ ├── day12.md │ │ ├── day13.md │ │ ├── day14.md │ │ ├── day15.md │ │ ├── day16.md │ │ ├── day17.md │ │ ├── day18.md │ │ ├── day19.md │ │ ├── day2.md │ │ ├── day3.md │ │ ├── day4.md │ │ ├── day5.md │ │ ├── day6.md │ │ ├── day7.md │ │ ├── day8.md │ │ └── day9.md ├── examples │ └── adventofcode │ │ ├── 2015 │ │ ├── day1.txt │ │ ├── day10.txt │ │ ├── day11.txt │ │ ├── day12.txt │ │ ├── day2.txt │ │ ├── day3.txt │ │ ├── day4.txt │ │ ├── day5.txt │ │ ├── day6.txt │ │ ├── day7.txt │ │ ├── day8.txt │ │ └── day9.txt │ │ ├── 2020 │ │ ├── day1.txt │ │ ├── day10.txt │ │ ├── day11.txt │ │ ├── day12.txt │ │ ├── day13.txt │ │ ├── day14.txt │ │ ├── day15.txt │ │ ├── day16.txt │ │ ├── day17.txt │ │ ├── day18.txt │ │ ├── day19.txt │ │ ├── day2.txt │ │ ├── day20.txt │ │ ├── day3.txt │ │ ├── day4.txt │ │ ├── day5.txt │ │ ├── day6.txt │ │ ├── day7.txt │ │ ├── day8.txt │ │ └── day9.txt │ │ └── main.rs └── src │ ├── lib.rs │ ├── year2015 │ ├── day1 │ │ ├── input.txt │ │ ├── mod.rs │ │ └── output.txt │ ├── day10 │ │ ├── input.txt │ │ ├── mod.rs │ │ └── output.txt │ ├── day11 │ │ ├── input.txt │ │ ├── mod.rs │ │ └── output.txt │ ├── day12 │ │ ├── input.txt │ │ ├── mod.rs │ │ └── output.txt │ ├── day2 │ │ ├── input.txt │ │ ├── mod.rs │ │ └── output.txt │ ├── day3 │ │ ├── input.txt │ │ ├── mod.rs │ │ └── output.txt │ ├── day4 │ │ ├── input.txt │ │ ├── mod.rs │ │ └── output.txt │ ├── day5 │ │ ├── input.txt │ │ ├── mod.rs │ │ └── output.txt │ ├── day6 │ │ ├── input.txt │ │ ├── mod.rs │ │ └── output.txt │ ├── day7 │ │ ├── input.txt │ │ ├── mod.rs │ │ └── output.txt │ ├── day8 │ │ ├── input.txt │ │ ├── mod.rs │ │ └── output.txt │ ├── day9 │ │ ├── input.txt │ │ ├── mod.rs │ │ └── output.txt │ └── mod.rs │ └── year2020 │ ├── day1 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day10 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day11 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day12 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day13 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day14 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day15 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day16 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day17 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day18 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day19 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day2 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day3 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day4 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day5 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day6 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day7 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day8 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ ├── day9 │ ├── input.txt │ ├── mod.rs │ └── output.txt │ └── mod.rs ├── bundle.txt ├── characters ├── Cargo.toml └── src │ └── lib.rs ├── clippy.toml ├── config ├── envoy.yaml └── sonic.cfg ├── consts ├── Cargo.toml └── src │ └── lib.rs ├── diesel.toml ├── google ├── Cargo.toml └── src │ ├── codejam │ ├── mod.rs │ └── year2008 │ │ ├── mod.rs │ │ └── round01 │ │ ├── _1_fly_swatter │ │ ├── analysis.md │ │ ├── input.txt │ │ ├── mod.rs │ │ ├── output.txt │ │ └── problem.md │ │ └── mod.rs │ ├── kickstart │ ├── mod.rs │ ├── year2013 │ │ ├── mod.rs │ │ └── round01 │ │ │ ├── _1_moist │ │ │ ├── input.txt │ │ │ ├── mod.rs │ │ │ ├── output.txt │ │ │ └── problem.md │ │ │ ├── _2_captain_hammer │ │ │ ├── input.txt │ │ │ ├── mod.rs │ │ │ ├── output.txt │ │ │ └── problem.md │ │ │ ├── _3_bad_horse │ │ │ ├── input.txt │ │ │ ├── mod.rs │ │ │ ├── output.txt │ │ │ └── problem.md │ │ │ └── mod.rs │ ├── year2020 │ │ ├── mod.rs │ │ └── round01 │ │ │ ├── _1_allocation │ │ │ ├── analysis.md │ │ │ ├── input.txt │ │ │ ├── mod.rs │ │ │ ├── output.txt │ │ │ └── problem.md │ │ │ └── mod.rs │ └── year2021 │ │ ├── mod.rs │ │ └── round01 │ │ ├── _1_k_goodness_string │ │ ├── analysis.md │ │ ├── input.txt │ │ ├── mod.rs │ │ ├── output.txt │ │ └── problem.md │ │ ├── _2_l_shaped_plots │ │ ├── analysis.md │ │ ├── input.txt │ │ ├── mod.rs │ │ ├── output.txt │ │ └── problem.md │ │ ├── _3_rabbit_house │ │ ├── analysis.md │ │ ├── input.txt │ │ ├── mod.rs │ │ ├── output.txt │ │ └── problem.md │ │ ├── _4_checksum │ │ ├── analysis.md │ │ ├── input.txt │ │ ├── output.txt │ │ └── problem.md │ │ └── mod.rs │ └── main.rs ├── gvc-sys ├── Cargo.toml ├── build.rs └── src │ ├── bindings.rs │ ├── csvg.cpp │ └── lib.rs ├── gvc ├── Cargo.toml └── src │ └── lib.rs ├── hackerrank ├── Cargo.toml └── src │ ├── hello_world │ ├── input00.txt │ ├── input01.txt │ ├── mod.rs │ ├── output00.txt │ ├── output01.txt │ └── problem.pdf │ ├── jumping_on_the_clouds │ ├── input00.txt │ ├── input01.txt │ ├── mod.rs │ ├── output00.txt │ ├── output01.txt │ └── problem.pdf │ ├── main.rs │ ├── repeated_string │ ├── input00.txt │ ├── input01.txt │ ├── mod.rs │ ├── output00.txt │ ├── output01.txt │ └── problem.pdf │ └── sock_merchant │ ├── input00.txt │ ├── input08.txt │ ├── mod.rs │ ├── output00.txt │ ├── output08.txt │ └── problem.pdf ├── ingest ├── Cargo.toml └── src │ └── main.rs ├── leetcode ├── Cargo.toml ├── desc │ ├── d0 │ │ ├── 1.md │ │ ├── 10.md │ │ ├── 11.md │ │ ├── 12.md │ │ ├── 13.md │ │ ├── 14.md │ │ ├── 15.md │ │ ├── 16.md │ │ ├── 17.md │ │ ├── 18.md │ │ ├── 19.md │ │ ├── 2.md │ │ ├── 20.md │ │ ├── 21.md │ │ ├── 22.md │ │ ├── 23.md │ │ ├── 24.md │ │ ├── 25.md │ │ ├── 26.md │ │ ├── 27.md │ │ ├── 28.md │ │ ├── 29.md │ │ ├── 3.md │ │ ├── 30.md │ │ ├── 31.md │ │ ├── 32.md │ │ ├── 33.md │ │ ├── 34.md │ │ ├── 35.md │ │ ├── 36.md │ │ ├── 37.md │ │ ├── 38.md │ │ ├── 39.md │ │ ├── 4.md │ │ ├── 40.md │ │ ├── 41.md │ │ ├── 42.md │ │ ├── 43.md │ │ ├── 44.md │ │ ├── 45.md │ │ ├── 46.md │ │ ├── 47.md │ │ ├── 48.md │ │ ├── 49.md │ │ ├── 5.md │ │ ├── 50.md │ │ ├── 51.md │ │ ├── 52.md │ │ ├── 53.md │ │ ├── 54.md │ │ ├── 55.md │ │ ├── 56.md │ │ ├── 57.md │ │ ├── 58.md │ │ ├── 59.md │ │ ├── 6.md │ │ ├── 60.md │ │ ├── 61.md │ │ ├── 62.md │ │ ├── 63.md │ │ ├── 64.md │ │ ├── 65.md │ │ ├── 66.md │ │ ├── 67.md │ │ ├── 68.md │ │ ├── 69.md │ │ ├── 7.md │ │ ├── 70.md │ │ ├── 71.md │ │ ├── 72.md │ │ ├── 73.md │ │ ├── 74.md │ │ ├── 75.md │ │ ├── 76.md │ │ ├── 77.md │ │ ├── 78.md │ │ ├── 79.md │ │ ├── 8.md │ │ ├── 80.md │ │ ├── 81.md │ │ ├── 82.md │ │ ├── 83.md │ │ ├── 84.md │ │ ├── 85.md │ │ ├── 86.md │ │ ├── 87.md │ │ ├── 88.md │ │ ├── 89.md │ │ ├── 9.md │ │ ├── 90.md │ │ ├── 91.md │ │ ├── 92.md │ │ ├── 93.md │ │ ├── 94.md │ │ ├── 95.md │ │ ├── 96.md │ │ ├── 97.md │ │ ├── 98.md │ │ └── 99.md │ ├── d1 │ │ ├── 100.md │ │ ├── 101.md │ │ ├── 102.md │ │ ├── 103.md │ │ ├── 104.md │ │ ├── 105.md │ │ ├── 106.md │ │ ├── 107.md │ │ ├── 108.md │ │ ├── 109.md │ │ ├── 110.md │ │ ├── 111.md │ │ ├── 112.md │ │ ├── 113.md │ │ ├── 114.md │ │ ├── 115.md │ │ ├── 118.md │ │ ├── 120.md │ │ ├── 121.md │ │ ├── 122.md │ │ ├── 123.md │ │ ├── 124.md │ │ ├── 125.md │ │ ├── 126.md │ │ ├── 127.md │ │ ├── 128.md │ │ ├── 129.md │ │ ├── 130.md │ │ ├── 131.md │ │ ├── 132.md │ │ ├── 134.md │ │ ├── 135.md │ │ ├── 136.md │ │ ├── 137.md │ │ ├── 139.md │ │ ├── 140.md │ │ ├── 143.md │ │ ├── 144.md │ │ ├── 145.md │ │ ├── 146.md │ │ ├── 147.md │ │ ├── 148.md │ │ ├── 149.md │ │ ├── 150.md │ │ ├── 151.md │ │ ├── 152.md │ │ ├── 153.md │ │ ├── 154.md │ │ ├── 155.md │ │ ├── 156.md │ │ ├── 157.md │ │ ├── 159.md │ │ ├── 161.md │ │ ├── 162.md │ │ ├── 163.md │ │ ├── 164.md │ │ ├── 165.md │ │ ├── 166.md │ │ ├── 167.md │ │ ├── 168.md │ │ ├── 169.md │ │ ├── 170.md │ │ ├── 171.md │ │ ├── 172.md │ │ ├── 173.md │ │ ├── 174.md │ │ ├── 179.md │ │ ├── 186.md │ │ ├── 187.md │ │ ├── 188.md │ │ ├── 189.md │ │ ├── 190.md │ │ ├── 191.md │ │ ├── 198.md │ │ └── 199.md │ ├── d10 │ │ ├── 1002.md │ │ ├── 1003.md │ │ ├── 1004.md │ │ ├── 1005.md │ │ ├── 1006.md │ │ ├── 1007.md │ │ ├── 1008.md │ │ ├── 1009.md │ │ ├── 1010.md │ │ ├── 1011.md │ │ ├── 1013.md │ │ ├── 1014.md │ │ ├── 1015.md │ │ ├── 1016.md │ │ ├── 1017.md │ │ ├── 1018.md │ │ ├── 1019.md │ │ ├── 1020.md │ │ ├── 1021.md │ │ ├── 1022.md │ │ ├── 1023.md │ │ ├── 1024.md │ │ ├── 1025.md │ │ ├── 1026.md │ │ ├── 1027.md │ │ ├── 1028.md │ │ ├── 1029.md │ │ ├── 1030.md │ │ ├── 1031.md │ │ ├── 1032.md │ │ ├── 1033.md │ │ ├── 1034.md │ │ ├── 1035.md │ │ ├── 1036.md │ │ ├── 1037.md │ │ ├── 1038.md │ │ ├── 1039.md │ │ ├── 1040.md │ │ ├── 1041.md │ │ ├── 1042.md │ │ ├── 1043.md │ │ ├── 1044.md │ │ ├── 1046.md │ │ ├── 1047.md │ │ ├── 1048.md │ │ ├── 1049.md │ │ ├── 1051.md │ │ ├── 1052.md │ │ ├── 1053.md │ │ ├── 1054.md │ │ ├── 1055.md │ │ ├── 1056.md │ │ ├── 1057.md │ │ ├── 1058.md │ │ ├── 1059.md │ │ ├── 1060.md │ │ ├── 1061.md │ │ ├── 1062.md │ │ ├── 1063.md │ │ ├── 1064.md │ │ ├── 1065.md │ │ ├── 1066.md │ │ ├── 1071.md │ │ ├── 1072.md │ │ ├── 1073.md │ │ ├── 1074.md │ │ ├── 1078.md │ │ ├── 1079.md │ │ ├── 1080.md │ │ ├── 1081.md │ │ ├── 1085.md │ │ ├── 1086.md │ │ ├── 1087.md │ │ ├── 1089.md │ │ ├── 1090.md │ │ ├── 1091.md │ │ ├── 1092.md │ │ ├── 1093.md │ │ ├── 1094.md │ │ ├── 1096.md │ │ └── 1099.md │ ├── d11 │ │ ├── 1100.md │ │ ├── 1101.md │ │ ├── 1102.md │ │ ├── 1103.md │ │ ├── 1104.md │ │ ├── 1105.md │ │ ├── 1106.md │ │ ├── 1108.md │ │ ├── 1109.md │ │ ├── 1110.md │ │ ├── 1111.md │ │ ├── 1114.md │ │ ├── 1116.md │ │ ├── 1117.md │ │ ├── 1118.md │ │ ├── 1119.md │ │ ├── 1120.md │ │ ├── 1121.md │ │ ├── 1122.md │ │ ├── 1123.md │ │ ├── 1124.md │ │ ├── 1128.md │ │ ├── 1129.md │ │ ├── 1130.md │ │ ├── 1131.md │ │ ├── 1133.md │ │ ├── 1134.md │ │ ├── 1135.md │ │ ├── 1136.md │ │ ├── 1137.md │ │ ├── 1138.md │ │ ├── 1139.md │ │ ├── 1140.md │ │ ├── 1143.md │ │ ├── 1144.md │ │ ├── 1145.md │ │ ├── 1146.md │ │ ├── 1147.md │ │ ├── 1150.md │ │ ├── 1151.md │ │ ├── 1152.md │ │ ├── 1154.md │ │ ├── 1155.md │ │ ├── 1156.md │ │ ├── 1160.md │ │ ├── 1161.md │ │ ├── 1162.md │ │ ├── 1163.md │ │ ├── 1165.md │ │ ├── 1166.md │ │ ├── 1167.md │ │ ├── 1168.md │ │ ├── 1169.md │ │ ├── 1170.md │ │ ├── 1171.md │ │ ├── 1172.md │ │ ├── 1175.md │ │ ├── 1176.md │ │ ├── 1177.md │ │ ├── 1180.md │ │ ├── 1181.md │ │ ├── 1182.md │ │ ├── 1183.md │ │ ├── 1184.md │ │ ├── 1185.md │ │ ├── 1186.md │ │ ├── 1188.md │ │ ├── 1189.md │ │ ├── 1190.md │ │ ├── 1191.md │ │ ├── 1192.md │ │ ├── 1195.md │ │ ├── 1196.md │ │ ├── 1197.md │ │ └── 1198.md │ ├── d12 │ │ ├── 1200.md │ │ ├── 1201.md │ │ ├── 1202.md │ │ ├── 1206.md │ │ ├── 1207.md │ │ ├── 1208.md │ │ ├── 1209.md │ │ ├── 1210.md │ │ ├── 1213.md │ │ ├── 1214.md │ │ ├── 1215.md │ │ ├── 1216.md │ │ ├── 1217.md │ │ ├── 1218.md │ │ ├── 1219.md │ │ ├── 1220.md │ │ ├── 1221.md │ │ ├── 1222.md │ │ ├── 1223.md │ │ ├── 1224.md │ │ ├── 1226.md │ │ ├── 1227.md │ │ ├── 1228.md │ │ ├── 1229.md │ │ ├── 1230.md │ │ ├── 1231.md │ │ ├── 1232.md │ │ ├── 1233.md │ │ ├── 1234.md │ │ ├── 1235.md │ │ ├── 1237.md │ │ ├── 1238.md │ │ ├── 1239.md │ │ ├── 1240.md │ │ ├── 1242.md │ │ ├── 1243.md │ │ ├── 1244.md │ │ ├── 1245.md │ │ ├── 1246.md │ │ ├── 1247.md │ │ ├── 1248.md │ │ ├── 1249.md │ │ ├── 1250.md │ │ ├── 1252.md │ │ ├── 1253.md │ │ ├── 1254.md │ │ ├── 1255.md │ │ ├── 1256.md │ │ ├── 1257.md │ │ ├── 1258.md │ │ ├── 1259.md │ │ ├── 1260.md │ │ ├── 1261.md │ │ ├── 1262.md │ │ ├── 1263.md │ │ ├── 1265.md │ │ ├── 1266.md │ │ ├── 1267.md │ │ ├── 1268.md │ │ ├── 1271.md │ │ ├── 1272.md │ │ ├── 1273.md │ │ ├── 1274.md │ │ ├── 1275.md │ │ ├── 1276.md │ │ ├── 1277.md │ │ ├── 1278.md │ │ ├── 1279.md │ │ ├── 1281.md │ │ ├── 1282.md │ │ ├── 1283.md │ │ ├── 1284.md │ │ ├── 1286.md │ │ ├── 1287.md │ │ ├── 1288.md │ │ ├── 1289.md │ │ ├── 1290.md │ │ ├── 1291.md │ │ ├── 1292.md │ │ ├── 1293.md │ │ ├── 1295.md │ │ ├── 1296.md │ │ ├── 1297.md │ │ ├── 1298.md │ │ └── 1299.md │ ├── d13 │ │ ├── 1300.md │ │ ├── 1302.md │ │ ├── 1304.md │ │ ├── 1305.md │ │ ├── 1306.md │ │ ├── 1309.md │ │ ├── 1310.md │ │ ├── 1311.md │ │ ├── 1312.md │ │ ├── 1313.md │ │ ├── 1314.md │ │ ├── 1315.md │ │ ├── 1316.md │ │ ├── 1317.md │ │ ├── 1318.md │ │ ├── 1319.md │ │ ├── 1320.md │ │ ├── 1323.md │ │ ├── 1324.md │ │ ├── 1325.md │ │ ├── 1326.md │ │ ├── 1328.md │ │ ├── 1329.md │ │ ├── 1330.md │ │ ├── 1331.md │ │ ├── 1332.md │ │ ├── 1333.md │ │ ├── 1334.md │ │ ├── 1335.md │ │ ├── 1337.md │ │ ├── 1338.md │ │ ├── 1339.md │ │ ├── 1340.md │ │ ├── 1342.md │ │ ├── 1343.md │ │ ├── 1344.md │ │ ├── 1346.md │ │ ├── 1347.md │ │ ├── 1348.md │ │ ├── 1351.md │ │ ├── 1352.md │ │ ├── 1353.md │ │ ├── 1356.md │ │ ├── 1357.md │ │ ├── 1358.md │ │ ├── 1359.md │ │ ├── 1360.md │ │ ├── 1361.md │ │ ├── 1362.md │ │ ├── 1365.md │ │ ├── 1366.md │ │ ├── 1367.md │ │ ├── 1368.md │ │ ├── 1370.md │ │ ├── 1371.md │ │ ├── 1372.md │ │ ├── 1374.md │ │ ├── 1375.md │ │ ├── 1376.md │ │ ├── 1377.md │ │ ├── 1380.md │ │ ├── 1381.md │ │ ├── 1382.md │ │ ├── 1383.md │ │ ├── 1385.md │ │ ├── 1386.md │ │ ├── 1387.md │ │ ├── 1389.md │ │ ├── 1390.md │ │ ├── 1391.md │ │ ├── 1394.md │ │ ├── 1395.md │ │ ├── 1396.md │ │ └── 1399.md │ ├── d14 │ │ ├── 1428.md │ │ ├── 1458.md │ │ ├── 1494.md │ │ └── 1499.md │ ├── d15 │ │ ├── 1531.md │ │ ├── 1533.md │ │ ├── 1538.md │ │ └── 1591.md │ ├── d16 │ │ ├── 1611.md │ │ ├── 1617.md │ │ ├── 1631.md │ │ ├── 1636.md │ │ ├── 1637.md │ │ ├── 1638.md │ │ ├── 1640.md │ │ ├── 1641.md │ │ ├── 1642.md │ │ ├── 1643.md │ │ ├── 1646.md │ │ ├── 1647.md │ │ ├── 1648.md │ │ ├── 1652.md │ │ ├── 1653.md │ │ ├── 1654.md │ │ ├── 1656.md │ │ ├── 1657.md │ │ ├── 1658.md │ │ ├── 1659.md │ │ ├── 1668.md │ │ ├── 1669.md │ │ ├── 1670.md │ │ ├── 1671.md │ │ ├── 1673.md │ │ ├── 1674.md │ │ ├── 1678.md │ │ ├── 1679.md │ │ ├── 1680.md │ │ ├── 1681.md │ │ ├── 1682.md │ │ ├── 1684.md │ │ ├── 1685.md │ │ ├── 1686.md │ │ ├── 1688.md │ │ ├── 1689.md │ │ ├── 1690.md │ │ ├── 1691.md │ │ ├── 1692.md │ │ ├── 1694.md │ │ ├── 1695.md │ │ ├── 1696.md │ │ ├── 1697.md │ │ └── 1698.md │ ├── d17 │ │ ├── 1700.md │ │ ├── 1701.md │ │ ├── 1702.md │ │ ├── 1704.md │ │ ├── 1705.md │ │ ├── 1706.md │ │ ├── 1708.md │ │ ├── 1710.md │ │ ├── 1711.md │ │ ├── 1712.md │ │ ├── 1713.md │ │ ├── 1716.md │ │ ├── 1717.md │ │ ├── 1718.md │ │ ├── 1720.md │ │ ├── 1721.md │ │ ├── 1722.md │ │ ├── 1725.md │ │ ├── 1726.md │ │ ├── 1727.md │ │ ├── 1730.md │ │ ├── 1732.md │ │ ├── 1733.md │ │ ├── 1734.md │ │ ├── 1736.md │ │ ├── 1737.md │ │ ├── 1738.md │ │ ├── 1740.md │ │ ├── 1746.md │ │ ├── 1748.md │ │ ├── 1749.md │ │ ├── 1750.md │ │ ├── 1752.md │ │ ├── 1753.md │ │ ├── 1754.md │ │ ├── 1758.md │ │ ├── 1760.md │ │ ├── 1762.md │ │ ├── 1769.md │ │ ├── 1773.md │ │ ├── 1779.md │ │ ├── 1784.md │ │ ├── 1790.md │ │ ├── 1791.md │ │ ├── 1792.md │ │ ├── 1794.md │ │ ├── 1796.md │ │ ├── 1797.md │ │ └── 1798.md │ ├── d18 │ │ ├── 1800.md │ │ ├── 1801.md │ │ ├── 1802.md │ │ ├── 1804.md │ │ ├── 1805.md │ │ ├── 1806.md │ │ ├── 1807.md │ │ ├── 1810.md │ │ ├── 1812.md │ │ ├── 1813.md │ │ ├── 1814.md │ │ ├── 1816.md │ │ ├── 1817.md │ │ ├── 1818.md │ │ ├── 1820.md │ │ ├── 1822.md │ │ ├── 1823.md │ │ ├── 1824.md │ │ ├── 1826.md │ │ ├── 1827.md │ │ ├── 1828.md │ │ ├── 1829.md │ │ ├── 1832.md │ │ ├── 1833.md │ │ ├── 1836.md │ │ ├── 1837.md │ │ ├── 1838.md │ │ ├── 1839.md │ │ ├── 1844.md │ │ ├── 1848.md │ │ ├── 1854.md │ │ ├── 1859.md │ │ ├── 1863.md │ │ ├── 1869.md │ │ ├── 1876.md │ │ ├── 1880.md │ │ ├── 1886.md │ │ ├── 1893.md │ │ └── 1897.md │ ├── d19 │ │ ├── 1903.md │ │ ├── 1909.md │ │ ├── 1913.md │ │ ├── 1920.md │ │ ├── 1925.md │ │ ├── 1929.md │ │ ├── 1933.md │ │ ├── 1935.md │ │ ├── 1941.md │ │ ├── 1945.md │ │ ├── 1952.md │ │ ├── 1957.md │ │ ├── 1961.md │ │ ├── 1967.md │ │ ├── 1971.md │ │ ├── 1974.md │ │ ├── 1979.md │ │ ├── 1984.md │ │ ├── 1991.md │ │ └── 1995.md │ ├── d2 │ │ ├── 200.md │ │ ├── 201.md │ │ ├── 202.md │ │ ├── 203.md │ │ ├── 204.md │ │ ├── 205.md │ │ ├── 206.md │ │ ├── 207.md │ │ ├── 208.md │ │ ├── 209.md │ │ ├── 210.md │ │ ├── 211.md │ │ ├── 212.md │ │ ├── 213.md │ │ ├── 214.md │ │ ├── 215.md │ │ ├── 216.md │ │ ├── 217.md │ │ ├── 218.md │ │ ├── 219.md │ │ ├── 220.md │ │ ├── 221.md │ │ ├── 222.md │ │ ├── 223.md │ │ ├── 224.md │ │ ├── 225.md │ │ ├── 226.md │ │ ├── 227.md │ │ ├── 228.md │ │ ├── 229.md │ │ ├── 230.md │ │ ├── 231.md │ │ ├── 232.md │ │ ├── 233.md │ │ ├── 234.md │ │ ├── 235.md │ │ ├── 236.md │ │ ├── 238.md │ │ ├── 239.md │ │ ├── 240.md │ │ ├── 241.md │ │ ├── 242.md │ │ ├── 243.md │ │ ├── 244.md │ │ ├── 245.md │ │ ├── 246.md │ │ ├── 247.md │ │ ├── 248.md │ │ ├── 249.md │ │ ├── 250.md │ │ ├── 251.md │ │ ├── 252.md │ │ ├── 253.md │ │ ├── 254.md │ │ ├── 255.md │ │ ├── 256.md │ │ ├── 257.md │ │ ├── 258.md │ │ ├── 259.md │ │ ├── 260.md │ │ ├── 261.md │ │ ├── 263.md │ │ ├── 264.md │ │ ├── 265.md │ │ ├── 266.md │ │ ├── 267.md │ │ ├── 268.md │ │ ├── 269.md │ │ ├── 270.md │ │ ├── 271.md │ │ ├── 272.md │ │ ├── 273.md │ │ ├── 274.md │ │ ├── 275.md │ │ ├── 276.md │ │ ├── 277.md │ │ ├── 278.md │ │ ├── 279.md │ │ ├── 280.md │ │ ├── 281.md │ │ ├── 282.md │ │ ├── 283.md │ │ ├── 285.md │ │ ├── 286.md │ │ ├── 287.md │ │ ├── 288.md │ │ ├── 289.md │ │ ├── 290.md │ │ ├── 291.md │ │ ├── 292.md │ │ ├── 293.md │ │ ├── 294.md │ │ ├── 295.md │ │ ├── 296.md │ │ ├── 297.md │ │ ├── 298.md │ │ └── 299.md │ ├── d20 │ │ ├── 2000.md │ │ ├── 2006.md │ │ ├── 2011.md │ │ ├── 2016.md │ │ ├── 2022.md │ │ ├── 2027.md │ │ ├── 2032.md │ │ ├── 2037.md │ │ ├── 2042.md │ │ ├── 2047.md │ │ ├── 2053.md │ │ ├── 2057.md │ │ ├── 2062.md │ │ ├── 2068.md │ │ ├── 2073.md │ │ ├── 2085.md │ │ ├── 2089.md │ │ ├── 2094.md │ │ └── 2099.md │ ├── d21 │ │ ├── 2103.md │ │ ├── 2108.md │ │ ├── 2114.md │ │ ├── 2119.md │ │ ├── 2124.md │ │ ├── 2129.md │ │ ├── 2133.md │ │ ├── 2138.md │ │ ├── 2144.md │ │ └── 2148.md │ ├── d3 │ │ ├── 300.md │ │ ├── 301.md │ │ ├── 302.md │ │ ├── 303.md │ │ ├── 304.md │ │ ├── 305.md │ │ ├── 306.md │ │ ├── 307.md │ │ ├── 309.md │ │ ├── 310.md │ │ ├── 311.md │ │ ├── 312.md │ │ ├── 313.md │ │ ├── 314.md │ │ ├── 315.md │ │ ├── 316.md │ │ ├── 317.md │ │ ├── 318.md │ │ ├── 319.md │ │ ├── 320.md │ │ ├── 321.md │ │ ├── 322.md │ │ ├── 323.md │ │ ├── 324.md │ │ ├── 325.md │ │ ├── 326.md │ │ ├── 328.md │ │ ├── 329.md │ │ ├── 330.md │ │ ├── 331.md │ │ ├── 332.md │ │ ├── 333.md │ │ ├── 334.md │ │ ├── 336.md │ │ ├── 337.md │ │ ├── 338.md │ │ ├── 339.md │ │ ├── 340.md │ │ ├── 341.md │ │ ├── 342.md │ │ ├── 343.md │ │ ├── 344.md │ │ ├── 345.md │ │ ├── 346.md │ │ ├── 347.md │ │ ├── 348.md │ │ ├── 349.md │ │ ├── 350.md │ │ ├── 351.md │ │ ├── 352.md │ │ ├── 353.md │ │ ├── 354.md │ │ ├── 355.md │ │ ├── 356.md │ │ ├── 357.md │ │ ├── 358.md │ │ ├── 359.md │ │ ├── 360.md │ │ ├── 361.md │ │ ├── 362.md │ │ ├── 363.md │ │ ├── 364.md │ │ ├── 365.md │ │ ├── 366.md │ │ ├── 367.md │ │ ├── 368.md │ │ ├── 369.md │ │ ├── 370.md │ │ ├── 371.md │ │ ├── 372.md │ │ ├── 373.md │ │ ├── 374.md │ │ ├── 375.md │ │ ├── 376.md │ │ ├── 377.md │ │ ├── 378.md │ │ ├── 379.md │ │ ├── 380.md │ │ ├── 381.md │ │ ├── 382.md │ │ ├── 383.md │ │ ├── 384.md │ │ ├── 385.md │ │ ├── 386.md │ │ ├── 387.md │ │ ├── 388.md │ │ ├── 389.md │ │ ├── 390.md │ │ ├── 391.md │ │ ├── 392.md │ │ ├── 393.md │ │ ├── 394.md │ │ ├── 395.md │ │ ├── 396.md │ │ ├── 397.md │ │ ├── 398.md │ │ └── 399.md │ ├── d4 │ │ ├── 400.md │ │ ├── 401.md │ │ ├── 402.md │ │ ├── 403.md │ │ ├── 404.md │ │ ├── 405.md │ │ ├── 406.md │ │ ├── 407.md │ │ ├── 408.md │ │ ├── 409.md │ │ ├── 410.md │ │ ├── 411.md │ │ ├── 412.md │ │ ├── 413.md │ │ ├── 414.md │ │ ├── 415.md │ │ ├── 416.md │ │ ├── 417.md │ │ ├── 418.md │ │ ├── 419.md │ │ ├── 420.md │ │ ├── 421.md │ │ ├── 422.md │ │ ├── 423.md │ │ ├── 424.md │ │ ├── 425.md │ │ ├── 432.md │ │ ├── 433.md │ │ ├── 434.md │ │ ├── 435.md │ │ ├── 436.md │ │ ├── 437.md │ │ ├── 438.md │ │ ├── 439.md │ │ ├── 440.md │ │ ├── 441.md │ │ ├── 442.md │ │ ├── 443.md │ │ ├── 444.md │ │ ├── 445.md │ │ ├── 446.md │ │ ├── 447.md │ │ ├── 448.md │ │ ├── 449.md │ │ ├── 450.md │ │ ├── 451.md │ │ ├── 452.md │ │ ├── 453.md │ │ ├── 454.md │ │ ├── 455.md │ │ ├── 456.md │ │ ├── 457.md │ │ ├── 458.md │ │ ├── 459.md │ │ ├── 460.md │ │ ├── 461.md │ │ ├── 462.md │ │ ├── 463.md │ │ ├── 464.md │ │ ├── 465.md │ │ ├── 467.md │ │ ├── 468.md │ │ ├── 469.md │ │ ├── 470.md │ │ ├── 471.md │ │ ├── 472.md │ │ ├── 473.md │ │ ├── 474.md │ │ ├── 475.md │ │ ├── 476.md │ │ ├── 477.md │ │ ├── 478.md │ │ ├── 479.md │ │ ├── 480.md │ │ ├── 481.md │ │ ├── 482.md │ │ ├── 484.md │ │ ├── 485.md │ │ ├── 486.md │ │ ├── 487.md │ │ ├── 488.md │ │ ├── 490.md │ │ ├── 491.md │ │ ├── 492.md │ │ ├── 493.md │ │ ├── 494.md │ │ ├── 495.md │ │ ├── 496.md │ │ ├── 497.md │ │ ├── 498.md │ │ └── 499.md │ ├── d5 │ │ ├── 500.md │ │ ├── 501.md │ │ ├── 502.md │ │ ├── 503.md │ │ ├── 504.md │ │ ├── 505.md │ │ ├── 506.md │ │ ├── 507.md │ │ ├── 508.md │ │ ├── 509.md │ │ ├── 513.md │ │ ├── 514.md │ │ ├── 515.md │ │ ├── 516.md │ │ ├── 517.md │ │ ├── 518.md │ │ ├── 519.md │ │ ├── 520.md │ │ ├── 521.md │ │ ├── 522.md │ │ ├── 523.md │ │ ├── 524.md │ │ ├── 525.md │ │ ├── 526.md │ │ ├── 527.md │ │ ├── 528.md │ │ ├── 529.md │ │ ├── 530.md │ │ ├── 531.md │ │ ├── 532.md │ │ ├── 533.md │ │ ├── 535.md │ │ ├── 536.md │ │ ├── 537.md │ │ ├── 538.md │ │ ├── 539.md │ │ ├── 540.md │ │ ├── 541.md │ │ ├── 542.md │ │ ├── 543.md │ │ ├── 544.md │ │ ├── 545.md │ │ ├── 546.md │ │ ├── 547.md │ │ ├── 548.md │ │ ├── 549.md │ │ ├── 551.md │ │ ├── 552.md │ │ ├── 553.md │ │ ├── 554.md │ │ ├── 555.md │ │ ├── 556.md │ │ ├── 557.md │ │ ├── 560.md │ │ ├── 561.md │ │ ├── 562.md │ │ ├── 563.md │ │ ├── 564.md │ │ ├── 565.md │ │ ├── 566.md │ │ ├── 567.md │ │ ├── 568.md │ │ ├── 572.md │ │ ├── 573.md │ │ ├── 575.md │ │ ├── 576.md │ │ ├── 581.md │ │ ├── 582.md │ │ ├── 583.md │ │ ├── 588.md │ │ ├── 591.md │ │ ├── 592.md │ │ ├── 593.md │ │ ├── 594.md │ │ ├── 598.md │ │ └── 599.md │ ├── d6 │ │ ├── 604.md │ │ ├── 605.md │ │ ├── 606.md │ │ ├── 609.md │ │ ├── 611.md │ │ ├── 616.md │ │ ├── 617.md │ │ ├── 621.md │ │ ├── 622.md │ │ ├── 623.md │ │ ├── 624.md │ │ ├── 625.md │ │ ├── 628.md │ │ ├── 630.md │ │ ├── 631.md │ │ ├── 632.md │ │ ├── 633.md │ │ ├── 634.md │ │ ├── 635.md │ │ ├── 636.md │ │ ├── 637.md │ │ ├── 638.md │ │ ├── 640.md │ │ ├── 641.md │ │ ├── 642.md │ │ ├── 643.md │ │ ├── 645.md │ │ ├── 646.md │ │ ├── 647.md │ │ ├── 648.md │ │ ├── 649.md │ │ ├── 650.md │ │ ├── 651.md │ │ ├── 652.md │ │ ├── 653.md │ │ ├── 654.md │ │ ├── 655.md │ │ ├── 657.md │ │ ├── 658.md │ │ ├── 659.md │ │ ├── 660.md │ │ ├── 661.md │ │ ├── 662.md │ │ ├── 663.md │ │ ├── 665.md │ │ ├── 666.md │ │ ├── 667.md │ │ ├── 668.md │ │ ├── 669.md │ │ ├── 670.md │ │ ├── 671.md │ │ ├── 672.md │ │ ├── 673.md │ │ ├── 674.md │ │ ├── 675.md │ │ ├── 676.md │ │ ├── 677.md │ │ ├── 678.md │ │ ├── 679.md │ │ ├── 680.md │ │ ├── 681.md │ │ ├── 682.md │ │ ├── 683.md │ │ ├── 684.md │ │ ├── 686.md │ │ ├── 687.md │ │ ├── 688.md │ │ ├── 689.md │ │ ├── 692.md │ │ ├── 693.md │ │ ├── 694.md │ │ ├── 695.md │ │ ├── 696.md │ │ ├── 697.md │ │ └── 698.md │ ├── d7 │ │ ├── 700.md │ │ ├── 701.md │ │ ├── 703.md │ │ ├── 704.md │ │ ├── 705.md │ │ ├── 706.md │ │ ├── 707.md │ │ ├── 709.md │ │ ├── 710.md │ │ ├── 712.md │ │ ├── 713.md │ │ ├── 714.md │ │ ├── 716.md │ │ ├── 717.md │ │ ├── 718.md │ │ ├── 719.md │ │ ├── 720.md │ │ ├── 721.md │ │ ├── 722.md │ │ ├── 723.md │ │ ├── 724.md │ │ ├── 725.md │ │ ├── 726.md │ │ ├── 727.md │ │ ├── 728.md │ │ ├── 729.md │ │ ├── 731.md │ │ ├── 732.md │ │ ├── 733.md │ │ ├── 734.md │ │ ├── 735.md │ │ ├── 736.md │ │ ├── 737.md │ │ ├── 738.md │ │ ├── 739.md │ │ ├── 740.md │ │ ├── 742.md │ │ ├── 743.md │ │ ├── 744.md │ │ ├── 746.md │ │ ├── 747.md │ │ ├── 748.md │ │ ├── 750.md │ │ ├── 751.md │ │ ├── 752.md │ │ ├── 753.md │ │ ├── 754.md │ │ ├── 755.md │ │ ├── 756.md │ │ ├── 758.md │ │ ├── 759.md │ │ ├── 760.md │ │ ├── 761.md │ │ ├── 762.md │ │ ├── 763.md │ │ ├── 764.md │ │ ├── 765.md │ │ ├── 766.md │ │ ├── 767.md │ │ ├── 768.md │ │ ├── 769.md │ │ ├── 770.md │ │ ├── 771.md │ │ ├── 772.md │ │ ├── 773.md │ │ ├── 774.md │ │ ├── 775.md │ │ ├── 776.md │ │ ├── 777.md │ │ ├── 778.md │ │ ├── 779.md │ │ ├── 780.md │ │ ├── 781.md │ │ ├── 783.md │ │ ├── 784.md │ │ ├── 785.md │ │ ├── 786.md │ │ ├── 787.md │ │ ├── 788.md │ │ ├── 789.md │ │ ├── 790.md │ │ ├── 791.md │ │ ├── 792.md │ │ ├── 794.md │ │ ├── 795.md │ │ ├── 796.md │ │ ├── 797.md │ │ └── 799.md │ ├── d8 │ │ ├── 800.md │ │ ├── 801.md │ │ ├── 802.md │ │ ├── 804.md │ │ ├── 805.md │ │ ├── 806.md │ │ ├── 807.md │ │ ├── 808.md │ │ ├── 809.md │ │ ├── 810.md │ │ ├── 811.md │ │ ├── 812.md │ │ ├── 813.md │ │ ├── 814.md │ │ ├── 815.md │ │ ├── 816.md │ │ ├── 817.md │ │ ├── 818.md │ │ ├── 819.md │ │ ├── 820.md │ │ ├── 821.md │ │ ├── 822.md │ │ ├── 823.md │ │ ├── 824.md │ │ ├── 825.md │ │ ├── 826.md │ │ ├── 827.md │ │ ├── 828.md │ │ ├── 829.md │ │ ├── 830.md │ │ ├── 831.md │ │ ├── 832.md │ │ ├── 833.md │ │ ├── 835.md │ │ ├── 836.md │ │ ├── 837.md │ │ ├── 838.md │ │ ├── 840.md │ │ ├── 841.md │ │ ├── 842.md │ │ ├── 843.md │ │ ├── 844.md │ │ ├── 845.md │ │ ├── 846.md │ │ ├── 847.md │ │ ├── 848.md │ │ ├── 849.md │ │ ├── 851.md │ │ ├── 852.md │ │ ├── 853.md │ │ ├── 854.md │ │ ├── 855.md │ │ ├── 856.md │ │ ├── 857.md │ │ ├── 858.md │ │ ├── 859.md │ │ ├── 860.md │ │ ├── 861.md │ │ ├── 862.md │ │ ├── 863.md │ │ ├── 865.md │ │ ├── 866.md │ │ ├── 867.md │ │ ├── 868.md │ │ ├── 869.md │ │ ├── 870.md │ │ ├── 871.md │ │ ├── 872.md │ │ ├── 873.md │ │ ├── 874.md │ │ ├── 875.md │ │ ├── 876.md │ │ ├── 877.md │ │ ├── 880.md │ │ ├── 881.md │ │ ├── 883.md │ │ ├── 884.md │ │ ├── 885.md │ │ ├── 886.md │ │ ├── 888.md │ │ ├── 889.md │ │ ├── 890.md │ │ ├── 891.md │ │ ├── 892.md │ │ ├── 893.md │ │ ├── 894.md │ │ ├── 895.md │ │ ├── 896.md │ │ ├── 897.md │ │ ├── 898.md │ │ └── 899.md │ └── d9 │ │ ├── 900.md │ │ ├── 901.md │ │ ├── 903.md │ │ ├── 904.md │ │ ├── 905.md │ │ ├── 907.md │ │ ├── 908.md │ │ ├── 909.md │ │ ├── 910.md │ │ ├── 911.md │ │ ├── 912.md │ │ ├── 914.md │ │ ├── 915.md │ │ ├── 916.md │ │ ├── 917.md │ │ ├── 918.md │ │ ├── 919.md │ │ ├── 921.md │ │ ├── 922.md │ │ ├── 923.md │ │ ├── 924.md │ │ ├── 925.md │ │ ├── 926.md │ │ ├── 929.md │ │ ├── 930.md │ │ ├── 931.md │ │ ├── 932.md │ │ ├── 933.md │ │ ├── 934.md │ │ ├── 935.md │ │ ├── 937.md │ │ ├── 938.md │ │ ├── 939.md │ │ ├── 941.md │ │ ├── 942.md │ │ ├── 944.md │ │ ├── 945.md │ │ ├── 946.md │ │ ├── 947.md │ │ ├── 948.md │ │ ├── 949.md │ │ ├── 950.md │ │ ├── 951.md │ │ ├── 953.md │ │ ├── 954.md │ │ ├── 955.md │ │ ├── 957.md │ │ ├── 958.md │ │ ├── 959.md │ │ ├── 960.md │ │ ├── 961.md │ │ ├── 962.md │ │ ├── 963.md │ │ ├── 965.md │ │ ├── 966.md │ │ ├── 967.md │ │ ├── 969.md │ │ ├── 970.md │ │ ├── 971.md │ │ ├── 972.md │ │ ├── 973.md │ │ ├── 974.md │ │ ├── 976.md │ │ ├── 977.md │ │ ├── 978.md │ │ ├── 979.md │ │ ├── 980.md │ │ ├── 981.md │ │ ├── 982.md │ │ ├── 983.md │ │ ├── 984.md │ │ ├── 985.md │ │ ├── 986.md │ │ ├── 987.md │ │ ├── 988.md │ │ ├── 989.md │ │ ├── 990.md │ │ ├── 991.md │ │ ├── 992.md │ │ ├── 993.md │ │ ├── 994.md │ │ ├── 995.md │ │ ├── 997.md │ │ ├── 998.md │ │ └── 999.md └── src │ ├── d0 │ ├── _10_regular_expression_matching.rs │ ├── _11_container_with_most_water.rs │ ├── _12_integer_to_roman.rs │ ├── _13_roman_to_integer.rs │ ├── _14_longest_common_prefix.rs │ ├── _15_three_sum.rs │ ├── _16_3sum_closest.rs │ ├── _17_letter_combinations_of_a_phone_number.rs │ ├── _18_4sum.rs │ ├── _19_remove_nth_node_from_end_of_list.rs │ ├── _1_two_sum.rs │ ├── _20_valid_parentheses.rs │ ├── _21_merge_two_sorted_lists.rs │ ├── _22_generate_parentheses.rs │ ├── _23_merge_k_sorted_lists.rs │ ├── _24_swap_nodes_in_pairs.rs │ ├── _25_reverse_nodes_in_k_group.rs │ ├── _26_remove_duplicates_from_sorted_array.rs │ ├── _27_remove_element.rs │ ├── _28_implement_str_str.rs │ ├── _29_divide_two_integers.rs │ ├── _2_add_two_numbers.rs │ ├── _30_substring_with_concatenation_of_all_words.rs │ ├── _31_next_permutation.rs │ ├── _32_longest_valid_parentheses.rs │ ├── _33_search_in_rotated_sorted_array.rs │ ├── _34_find_first_and_last_position_of_elements_in_sorted_array.rs │ ├── _35_search_insert_position.rs │ ├── _36_valid_sudoku.rs │ ├── _37_sudoku_solver.rs │ ├── _38_count_and_say.rs │ ├── _39_combination_sum.rs │ ├── _3_longest_substring_without_repeating_characters.rs │ ├── _40_combination_sum_2.rs │ ├── _41_first_missing_positive.rs │ ├── _42_trapping_rain_water.rs │ ├── _43_multiply_strings.rs │ ├── _44_wildcard_matching.rs │ ├── _45_jump_game_2.rs │ ├── _46_permutations.rs │ ├── _47_permutations_2.rs │ ├── _48_rotate_image.rs │ ├── _49_group_anagrams.rs │ ├── _4_median_of_two_sorted_arrays.rs │ ├── _50_pow_x_n.rs │ ├── _51_n_queens.rs │ ├── _52_n_queens_2.rs │ ├── _53_maximum_subarray.rs │ ├── _54_spiral_matrix.rs │ ├── _55_jump_game.rs │ ├── _56_merge_intervals.rs │ ├── _57_insert_interval.rs │ ├── _58_length_of_last_word.rs │ ├── _59_spiral_matrix_2.rs │ ├── _5_longest_palindromic_substring.rs │ ├── _60_permutation_sequence.rs │ ├── _61_rotate_list.rs │ ├── _62_unique_paths.rs │ ├── _63_unique_paths_2.rs │ ├── _64_minimum_path_sum.rs │ ├── _65_valid_number.rs │ ├── _66_plus_one.rs │ ├── _67_add_binary.rs │ ├── _68_text_justification.rs │ ├── _69_sqrt.rs │ ├── _6_zigzag_conversion.rs │ ├── _70_climbing_stairs.rs │ ├── _71_simplify_path.rs │ ├── _72_edit_distance.rs │ ├── _73_set_matrix_zeroes.rs │ ├── _74_search_a_2d_matrix.rs │ ├── _75_sort_colors.rs │ ├── _76_minimum_window_substring.rs │ ├── _77_combinations.rs │ ├── _78_subsets.rs │ ├── _79_word_search.rs │ ├── _7_reverse_integer.rs │ ├── _80_remove_duplicates_from_sorted_array_2.rs │ ├── _81_search_in_rotated_sorted_array_2.rs │ ├── _82_remove_duplicates_from_sorted_list_2.rs │ ├── _83_remove_duplicates_from_sorted_list.rs │ ├── _84_largest_rectangle_in_histogram.rs │ ├── _85_maximal_rectangle.rs │ ├── _86_partition_list.rs │ ├── _87_scramble_string.rs │ ├── _88_merge_sorted_array.rs │ ├── _89_gray_code.rs │ ├── _8_string_to_integer.rs │ ├── _90_subsets_2.rs │ ├── _91_decode_ways.rs │ ├── _92_reverse_linked_list_2.rs │ ├── _93_restore_ip_addresses.rs │ ├── _94_binary_tree_inorder_traversal.rs │ ├── _95_unique_binary_search_trees_2.rs │ ├── _96_unique_binary_search_trees.rs │ ├── _97_interleaving_string.rs │ ├── _98_validate_binary_search_tree.rs │ ├── _99_recover_binary_search_tree.rs │ ├── _9_palindrome_number.rs │ └── mod.rs │ ├── d1 │ ├── _100_same_tree.rs │ ├── _101_symmetric_tree.rs │ ├── _102_binary_tree_level_order_traversal.rs │ ├── _103_binary_tree_zigzag_level_order_traversal.rs │ ├── _104_maximum_depth_of_binary_tree.rs │ ├── _105_construct_binary_tree_from_preorder_and_inorder_traversal.rs │ ├── _106_construct_binary_tree_from_inorder_and_postorder_traversal.rs │ ├── _107_binary_tree_level_order_traversal_2.rs │ ├── _108_convert_sorted_array_binary_search_tree.rs │ ├── _109_convert_sorted_list_to_binary_search_tree.rs │ ├── _110_balanced_binary_tree.rs │ ├── _111_minimum_depth_of_binary_tree.rs │ ├── _112_path_sum.rs │ ├── _113_path_sum_2.rs │ ├── _114_flatten_binary_tree_to_linked_list.rs │ ├── _115_distinct_subsequences.rs │ ├── _118_pascal_triangle.rs │ ├── _119_pascal_triangle_2.rs │ ├── _120_triangle.rs │ ├── _121_best_time_to_buy_and_sell_stock.rs │ ├── _122_best_time_to_buy_and_sell_stock_2.rs │ ├── _123_best_time_to_buy_and_sell_stock_3.rs │ ├── _124_binary_tree_maximum_path_sum.rs │ ├── _125_valid_palindrome.rs │ ├── _126_word_ladder_2.rs │ ├── _127_word_ladder.rs │ ├── _128_longest_consecutive_sequence.rs │ ├── _129_sum_root_to_leaf_numbers.rs │ ├── _130_surrounded_regions.rs │ ├── _131_palindrome_partitioning.rs │ ├── _132_palindrome_partitioning_2.rs │ ├── _134_gas_station.rs │ ├── _135_candy.rs │ ├── _136_single_number.rs │ ├── _137_single_number_2.rs │ ├── _139_word_break.rs │ ├── _140_word_break_2.rs │ ├── _143_reorder_list.rs │ ├── _144_binary_tree_preorder_traversal.rs │ ├── _145_binary_tree_postorder_traversal.rs │ ├── _146_lru_cache.rs │ ├── _147_insertion_sort_list.rs │ ├── _148_sort_list.rs │ ├── _149_max_points_on_a_line.rs │ ├── _150_evaluate_reverse_polish_notation.rs │ ├── _151_reverse_words_in_a_string.rs │ ├── _152_maximum_product_subarray.rs │ ├── _153_find_minimum_in_rotated_sorted_array.rs │ ├── _155_min_stack.rs │ ├── _156_binary_tree_upside_down.rs │ ├── _157_read_n_characters_given_read4.rs │ ├── _159_longest_substring_with_at_most_two_distinc_characters.rs │ ├── _161_one_edit_distance.rs │ ├── _162_find_peak_element.rs │ ├── _163_missing_ranges.rs │ ├── _164_maximum_gap.rs │ ├── _165_compare_version_numbers.rs │ ├── _166_fraction_to_recurring_decimal.rs │ ├── _167_two_sum_2.rs │ ├── _168_excel_sheet_column_title.rs │ ├── _169_majority_element.rs │ ├── _170_two_sum_3.rs │ ├── _171_excel_sheet_column_number.rs │ ├── _172_factorial_trailing_zeroes.rs │ ├── _173_binary_search_tree_iterator.rs │ ├── _174_dungeon_game.rs │ ├── _179_largest_number.rs │ ├── _186_reverse_words_in_a_string_2.rs │ ├── _187_repeated_dna_sequences.rs │ ├── _188_best_time_to_buy_and_sell_stock_4.rs │ ├── _189_rotate_array.rs │ ├── _190_reverse_bits.rs │ ├── _191_number_of_1_bits.rs │ ├── _198_house_robber.rs │ ├── _199_binary_tree_right_side_view.rs │ └── mod.rs │ ├── d10 │ ├── _1002_find_common_characters.rs │ ├── _1003_check_if_word_is_valid_after_substitutions.rs │ ├── _1004_max_consecutive_ones_3.rs │ ├── _1005_maximize_sum_of_array_after_k_negations.rs │ ├── _1006_clumsy_factorial.rs │ ├── _1007_minimum_domino_rotations_for_equal_row.rs │ ├── _1008_construct_binary_search_tree_from_preorder_traversal.rs │ ├── _1009_complement_of_base_10_integer.rs │ ├── _1010_pairs_of_songs_with_total_durations_divisible_by_60.rs │ ├── _1011_capacity_to_ship_packages_within_d_days.rs │ ├── _1013_partition_array_into_three_parts_with_equal_sum.rs │ ├── _1014_best_sightseeing_pair.rs │ ├── _1015_smallest_integer_divisible_by_k.rs │ ├── _1016_binary_string_with_substrings_representing_1_to_n.rs │ ├── _1017_convert_to_base_minus_2.rs │ ├── _1018_binary_prefix_divisible_by_5.rs │ ├── _1019_next_greater_node_in_linked_list.rs │ ├── _1020_number_of_enclaves.rs │ ├── _1021_remove_outermost_parentheses.rs │ ├── _1022_sum_root_to_leaf_binary_number.rs │ ├── _1023_camelcase_matching.rs │ ├── _1024_video_stitching.rs │ ├── _1025_divisor_game.rs │ ├── _1026_maximum_difference_between_node_and_ancestor.rs │ ├── _1027_longest_arithmetic_sequence.rs │ ├── _1028_recover_a_tree_from_preorder_traversal.rs │ ├── _1029_two_city_scheduling.rs │ ├── _1030_matrix_cells_in_distance_order.rs │ ├── _1031_maximum_sum_of_two_non_overlapping_subarrays.rs │ ├── _1032_stream_of_characters.rs │ ├── _1033_moving_stones_until_consecutive.rs │ ├── _1034_coloring_a_border.rs │ ├── _1035_uncrossed_lines.rs │ ├── _1036_escape_a_large_maze.rs │ ├── _1037_valid_boomerang.rs │ ├── _1038_binary_search_tree_to_greater_sum_tree.rs │ ├── _1039_minimum_score_triangulation_of_polygon.rs │ ├── _1040_moving_stones_until_consecutive_2.rs │ ├── _1041_robot_bounded_in_circle.rs │ ├── _1042_flower_planting_with_no_adjacent.rs │ ├── _1043_partition_array_for_maximum_sum.rs │ ├── _1044_longest_duplicate_substring.rs │ ├── _1046_last_stone_weight.rs │ ├── _1047_remove_all_adjacent_duplicates_in_string.rs │ ├── _1048_longest_string_chain.rs │ ├── _1049_last_stone_weight_2.rs │ ├── _1051_height_checker.rs │ ├── _1052_grumpy_bookstore_owner.rs │ ├── _1053_previous_permutation_with_one_swap.rs │ ├── _1054_distant_barcodes.rs │ ├── _1055_shortest_way_to_form_string.rs │ ├── _1056_confusing_number.rs │ ├── _1057_campus_bikes.rs │ ├── _1058_minimize_rounding_error_to_meet_target.rs │ ├── _1059_all_paths_from_source_lead_to_destination.rs │ ├── _1060_missing_element_in_sorted_array.rs │ ├── _1061_lexicographically_smallest_equivalent_string.rs │ ├── _1062_longest_repeating_substring.rs │ ├── _1063_number_of_valid_subarrays.rs │ ├── _1064_fixed_point.rs │ ├── _1065_index_pairs_of_a_string.rs │ ├── _1066_campus_bikes_2.rs │ ├── _1071_greatest_common_divisor_of_strings.rs │ ├── _1072_flip_columns_for_maximum_number_of_equal_rows.rs │ ├── _1073_adding_two_negabinary_numbers.rs │ ├── _1074_number_of_submatrices_that_sum_to_target.rs │ ├── _1078_occurrences_after_bigram.rs │ ├── _1079_letter_tile_possibilities.rs │ ├── _1080_insufficient_nodes_in_root_to_leaf_paths.rs │ ├── _1081_smallest_subsequence_of_distinct_characters.rs │ ├── _1085_sum_of_digits_in_the_minmum_number.rs │ ├── _1086_high_five.rs │ ├── _1087_brace_expansion.rs │ ├── _1089_duplicate_zeros.rs │ ├── _1090_largest_values_from_labels.rs │ ├── _1091_shortest_path_in_binary_matrix.rs │ ├── _1092_shortest_common_supersequence.rs │ ├── _1093_statistics_from_a_large_sample.rs │ ├── _1094_car_pooling.rs │ ├── _1096_brace_expansion_2.rs │ ├── _1099_two_sum_less_than_k.rs │ └── mod.rs │ ├── d11 │ ├── _1100_find_k_length_substrings_with_no_repeated_characters.rs │ ├── _1101_the_earliest_moment_when_everyone_become_friends.rs │ ├── _1102_path_with_maximum_minimum_value.rs │ ├── _1103_distribute_candies_to_people.rs │ ├── _1104_path_in_zigzag_labelled_binary_tree.rs │ ├── _1105_filling_bookcase_shelves.rs │ ├── _1106_parsing_a_boolean_expression.rs │ ├── _1108_defanging_an_ip_address.rs │ ├── _1109_corp_flight_bookings.rs │ ├── _1110_delete_nodes_and_return_forest.rs │ ├── _1111_maximum_nesting_depth_of_two_valid_parentheses_strings.rs │ ├── _1114_print_in_order.rs │ ├── _1115_print_foobar_alternately.rs │ ├── _1116_print_zero_even_odd.rs │ ├── _1117_building_h2o.rs │ ├── _1118_number_of_days_in_a_month.rs │ ├── _1119_remove_vowels_from_a_string.rs │ ├── _1120_maximum_average_subtree.rs │ ├── _1121_divide_array_into_increasing_sequences.rs │ ├── _1122_relative_sort_array.rs │ ├── _1123_lowest_common_ancestor_or_deepest_leaves.rs │ ├── _1124_longest_well_performing_interval.rs │ ├── _1128_number_of_equivalent_domino_pairs.rs │ ├── _1129_shortest_path_with_alternating_colors.rs │ ├── _1130_minimum_cost_tree_from_leaf_values.rs │ ├── _1131_maximum_of_absolute_value_expression.rs │ ├── _1133_largest_unique_number.rs │ ├── _1134_armstrong_number.rs │ ├── _1135_connecting_cities_with_minimum_cost.rs │ ├── _1136_parallel_courses.rs │ ├── _1137_n_th_tribonacci_number.rs │ ├── _1138_alphabet_board_path.rs │ ├── _1139_largest_1_bordered_square.rs │ ├── _1140_stone_game_2.rs │ ├── _1143_longest_common_subsequence.rs │ ├── _1144_decrease_elements_to_make_array_zigzag.rs │ ├── _1145_binary_tree_coloring_game.rs │ ├── _1146_snapshot_array.rs │ ├── _1147_longest_chunked_palindrome_decomposition.rs │ ├── _1150_check_if_a_number_is_majority_element_in_a_sorted_array.rs │ ├── _1151_minimum_swaps_to_group_all_1s_together.rs │ ├── _1152_analyze_user_website_visit_pattern.rs │ ├── _1154_day_of_the_year.rs │ ├── _1155_number_of_dice_rolls_with_target_sum.rs │ ├── _1156_swap_for_longest_repeated_character_substring.rs │ ├── _1160_find_words_that_can_be_formed_by_characters.rs │ ├── _1161_maximum_level_sum_of_a_binary_tree.rs │ ├── _1162_as_far_from_land_as_possible.rs │ ├── _1163_last_substring_in_lexicographical_order.rs │ ├── _1165_single_row_keyboard.rs │ ├── _1166_design_file_system.rs │ ├── _1167_minimum_cost_to_connect_sticks.rs │ ├── _1168_optimize_water_distribution_in_a_village.rs │ ├── _1169_invalid_transactions.rs │ ├── _1170_compare_strings_by_frequency_of_the_smallest_character.rs │ ├── _1171_remove_zero_sum_consecutive_nodes_from_linked_list.rs │ ├── _1172_dinner_plate_stacks.rs │ ├── _1175_prime_arrangements.rs │ ├── _1176_diet_plan_performance.rs │ ├── _1177_can_make_palindrome_from_substring.rs │ ├── _1180_count_substring_with_only_one_distinct_letter.rs │ ├── _1181_before_and_after_puzzle.rs │ ├── _1182_shortest_distance_to_target_color.rs │ ├── _1183_maximum_number_of_ones.rs │ ├── _1184_distance_between_bus_stops.rs │ ├── _1185_day_of_the_week.rs │ ├── _1186_maximum_subarray_sum_with_one_deletion.rs │ ├── _1188_design_bounded_blocking_queue.rs │ ├── _1189_maximum_number_of_balloons.rs │ ├── _1190_reverse_substrings_between_each_pair_of_parentheses.rs │ ├── _1191_k_concatenation_maximum_sum.rs │ ├── _1192_critical_connections_in_a_network.rs │ ├── _1195_fizz_buzz_multithreaded.rs │ ├── _1196_how_many_apples_can_you_put_into_the_basket.rs │ ├── _1197_minimum_knight_moves.rs │ ├── _1197_minimum_knight_moves_math.rs │ ├── _1198_find_smallest_common_element_in_all_rows.rs │ └── mod.rs │ ├── d12 │ ├── _1200_minimum_absolute_difference.rs │ ├── _1201_ugly_number_3.rs │ ├── _1202_smallest_string_with_swaps.rs │ ├── _1203_sort_items_by_groups_respecting_dependencies.rs │ ├── _1206_design_skiplist.rs │ ├── _1207_unique_number_of_occurrences.rs │ ├── _1208_get_equal_substrings_within_budget.rs │ ├── _1209_remove_all_adjacent_duplicates_in_string_2.rs │ ├── _1210_minimum_moves_to_reach_target_with_rotations.rs │ ├── _1213_intersection_of_three_sorted_arrays.rs │ ├── _1214_two_sum_bsts.rs │ ├── _1215_stepping_numbers.rs │ ├── _1216_valid_palindrome_3.rs │ ├── _1217_play_with_chips.rs │ ├── _1218_longest_arithmetic_subsequence_of_given_difference.rs │ ├── _1219_path_with_maximum_gold.rs │ ├── _1220_count_vowels_permutation.rs │ ├── _1221_split_a_string_in_balanced_strings.rs │ ├── _1222_queens_that_can_attack_the_king.rs │ ├── _1223_dice_roll_simulation.rs │ ├── _1224_maximum_equal_frequency.rs │ ├── _1226_the_dining_philosophers.rs │ ├── _1227_airplane_seat_assignment_probability.rs │ ├── _1228_missing_number_in_arithmetic_progression.rs │ ├── _1229_meeting_scheduler.rs │ ├── _1230_toss_strange_coins.rs │ ├── _1231_divide_chocolate.rs │ ├── _1232_check_if_it_is_a_straight_line.rs │ ├── _1233_remove_sub_folders_from_the_filesystem.rs │ ├── _1234_replace_the_substring_for_balanced_string.rs │ ├── _1235_maximum_profit_in_job_scheduling.rs │ ├── _1237_find_positive_integer_solution_for_a_given_equation.rs │ ├── _1238_circular_permutation_in_binary_representation.rs │ ├── _1239_maximum_length_of_concatenated_string_with_unique_characters.rs │ ├── _1240_tiling_a_rectangle_with_the_fewest_squares.rs │ ├── _1242_web_crawler_multithreaded.rs │ ├── _1243_array_transformation.rs │ ├── _1244_design_a_leaderboard.rs │ ├── _1245_tree_diameter.rs │ ├── _1246_palindrome_removal.rs │ ├── _1247_minimum_swaps_to_make_strings_equal.rs │ ├── _1248_count_number_of_nice_subarrays.rs │ ├── _1249_minimum_remove_to_make_valid_parentheses.rs │ ├── _1250_check_if_it_is_a_good_array.rs │ ├── _1252_cells_with_odd_values_in_a_matrix.rs │ ├── _1253_reconstruct_a_2_row_binary_matrix.rs │ ├── _1254_number_of_closed_islands.rs │ ├── _1255_maximum_score_words_formed_by_letters.rs │ ├── _1256_encode_number.rs │ ├── _1257_smallest_common_region.rs │ ├── _1258_synonymous_sentences.rs │ ├── _1259_handshakes_that_don_t_cross.rs │ ├── _1260_shift_2d_grid.rs │ ├── _1261_find_elements_in_contaminated_binary_tree.rs │ ├── _1262_greatest_sum_divisible_by_three.rs │ ├── _1263_minimum_moves_to_move_a_box_to_their_target_location.rs │ ├── _1266_minimum_time_visition_all_points.rs │ ├── _1267_count_servers_that_communicate.rs │ ├── _1268_search_suggestions_system.rs │ ├── _1271_hexspeak.rs │ ├── _1272_remove_interval.rs │ ├── _1273_delete_tree_nodes.rs │ ├── _1274_number_of_ships_in_rectangle.rs │ ├── _1275_find_winner_on_a_tic_tac_toe_game.rs │ ├── _1276_number_of_burgers_with_no_waste_of_ingredients.rs │ ├── _1277_count_square_submatrices_with_all_ones.rs │ ├── _1278_palindrome_partitioning_3.rs │ ├── _1279_traffic_light_controlled_intersection.rs │ ├── _1281_subtract_the_product_and_sum_of_digits_of_an_integer.rs │ ├── _1282_group_the_people_given_the_group_size_they_belong_to.rs │ ├── _1283_find_the_smallest_divisor_given_a_threshold.rs │ ├── _1284_minimum_number_of_flips_to_convert_binary_matrix_to_zero_matrix.rs │ ├── _1286_iterator_for_combination.rs │ ├── _1287_element_appearing_more_than_25_in_sorted_array.rs │ ├── _1288_remove_covered_intervals.rs │ ├── _1289_minimum_falling_path_sum_2.rs │ ├── _1290_convert_binary_number_in_a_linked_list_to_integer.rs │ ├── _1291_sequential_digits.rs │ ├── _1292_maximum_side_length_of_a_square_with_sum_less_than_or_equal_to_threshold.rs │ ├── _1293_shortest_path_in_a_grid_with_obstacles_elimination.rs │ ├── _1295_find_numbers_with_even_number_of_digits.rs │ ├── _1296_divide_array_in_sets_of_k_consecutive_numbers.rs │ ├── _1297_maximum_number_of_occurrences_of_a_substring.rs │ ├── _1298_maximum_candies_you_can_get_from_boxes.rs │ ├── _1299_replace_elements_with_greatest_element_on_right_side.rs │ └── mod.rs │ ├── d13 │ ├── _1300_sum_of_mutated_array_closest_to_target.rs │ ├── _1302_deepest_leaves_sum.rs │ ├── _1304_find_n_unique_integers_sum_up_to_zero.rs │ ├── _1305_all_elements_in_two_binary_search_tree.rs │ ├── _1306_jump_game_3.rs │ ├── _1309_decrypt_string_from_alphabet_to_integer_mapping.rs │ ├── _1310_xor_queries_of_a_subarray.rs │ ├── _1311_get_watched_videos_by_your_friends.rs │ ├── _1312_minimum_insertion_steps_to_make_a_string_palindrome.rs │ ├── _1313_decompres_run_length_encoded_list.rs │ ├── _1314_matrix_block_sum.rs │ ├── _1315_sum_of_nodes_with_even_valued_grandparent.rs │ ├── _1316_distinct_echo_substrings.rs │ ├── _1317_convert_integer_to_the_sum_of_two_no_zero_integers.rs │ ├── _1318_minimum_flips_to_make_a_or_b_equal_to_c.rs │ ├── _1319_number_of_operations_to_make_network_connected.rs │ ├── _1320_minimum_distance_to_type_a_word_using_two_fingers.rs │ ├── _1323_maximum_69_number.rs │ ├── _1324_print_words_vertically.rs │ ├── _1325_delete_leaves_with_a_given_value.rs │ ├── _1326_minimum_number_of_taps_to_open_to_water_a_garden.rs │ ├── _1328_break_a_palindrome.rs │ ├── _1329_sort_the_matrix_diagonally.rs │ ├── _1330_reverse_subarray_to_maximize_array_value.rs │ ├── _1331_rank_transform_of_an_array.rs │ ├── _1332_remove_palindromic_subsequences.rs │ ├── _1333_filter_restaurants_by_vengan_friendly_price_and_distance.rs │ ├── _1334_find_the_city_with_the_smallest_number_of_neighbors_at_a_threshold_distance.rs │ ├── _1335_minimum_difficulty_of_a_job_schedule.rs │ ├── _1337_the_k_weakest_rows_in_a_matrix.rs │ ├── _1338_reduce_array_size_to_the_half.rs │ ├── _1339_maximum_product_of_splitted_binary_tree.rs │ ├── _1340_jump_game_5.rs │ ├── _1342_number_of_steps_to_reduce_a_number_to_zero.rs │ ├── _1343_number_of_sub_arrays_of_size_k_and_average_greater_than_or_equal_to_threshold.rs │ ├── _1344_angle_between_hands_of_a_clock.rs │ ├── _1346_check_if_n_and_its_double_exist.rs │ ├── _1347_minimum_number_of_steps_to_make_two_strings_anagram.rs │ ├── _1348_tweet_counts_per_frequency.rs │ ├── _1351_count_negative_numbers_in_a_sorted_matrix.rs │ ├── _1352_product_of_the_last_k_numbers.rs │ ├── _1353_maximum_number_of_events_that_can_be_attended.rs │ ├── _1356_sort_integers_by_the_number_of_1_bits.rs │ ├── _1357_apply_discount_every_n_orders.rs │ ├── _1358_number_of_substrings_containing_all_three_characters.rs │ ├── _1359_count_all_valid_pickup_and_delivery_options.rs │ ├── _1360_number_of_days_between_two_dates.rs │ ├── _1361_validate_binary_tree_nodes.rs │ ├── _1362_closest_divisors.rs │ ├── _1365_how_many_numbers_are_smaller_than_the_current_number.rs │ ├── _1366_rank_teams_by_votes.rs │ ├── _1367_linked_list_in_binary_tree.rs │ ├── _1368_minimum_cost_to_make_at_least_one_valid_path_in_a_grid.rs │ ├── _1370_increasing_decreasing_string.rs │ ├── _1371_find_the_longest_substring_containing_vowels_in_even_counts.rs │ ├── _1372_longest_zigzag_path_in_a_binary_tree.rs │ ├── _1374_generate_a_string_with_characters_that_have_odd_counts.rs │ ├── _1375_bulb_switcher_3.rs │ ├── _1376_time_needed_to_inform_all_employees.rs │ ├── _1377_frog_position_after_t_seconds.rs │ ├── _1380_lucky_numbers_in_a_matrix.rs │ ├── _1381_design_a_stack_with_increment_operation.rs │ ├── _1382_balance_a_binary_search_tree.rs │ ├── _1383_maximum_performance_of_a_team.rs │ ├── _1385_find_the_distance_value_between_two_arrays.rs │ ├── _1386_cinema_seat_allocation.rs │ ├── _1387_sort_integers_by_the_power_value.rs │ ├── _1389_create_target_array_in_the_given_order.rs │ ├── _1390_four_divisors.rs │ ├── _1391_check_if_there_is_a_valid_path_in_a_grid.rs │ ├── _1394_find_lucky_integer_in_an_array.rs │ ├── _1395_count_number_of_teams.rs │ ├── _1396_design_underground_system.rs │ ├── _1399_count_largest_group.rs │ └── mod.rs │ ├── d14 │ ├── _1400_construct_k_palindrome_strings.rs │ ├── _1401_circle_and_rectangle_overlapping.rs │ ├── _1402_reducing_dishes.rs │ ├── _1403_minimum_subsequence_in_non_increasing_order.rs │ ├── _1404_number_of_steps_to_reduce_a_number_in_binary_representation_to_one.rs │ ├── _1405_longest_happy_string.rs │ ├── _1406_stone_game_3.rs │ ├── _1408_string_matching_in_an_array.rs │ ├── _1409_queries_on_a_permutation_with_key.rs │ ├── _1410_html_entity_parser.rs │ ├── _1411_number_of_ways_to_paint_n3_grid.rs │ ├── _1413_minimum_value_to_get_positive_step_by_step_sum.rs │ ├── _1414_find_the_minimum_number_of_fibonacci_numbers_whoes_sum_is_k.rs │ ├── _1415_the_k_th_lexicographical_string_of_all_happy_strings_of_length_n.rs │ ├── _1417_reformat_the_string.rs │ ├── _1418_display_table_of_food_orders_in_a_restaurant.rs │ ├── _1419_minimum_number_of_frogs_croaking.rs │ ├── _1420_build_array_where_you_can_find_the_maximum_exactly_k_comparisons.rs │ ├── _1422_maximum_score_after_splitting_a_string.rs │ ├── _1423_maximum_points_you_can_obtain_from_cards.rs │ ├── _1424_diagonal_traversel_2.rs │ ├── _1426_counting_elements.rs │ ├── _1427_perform_string_shifts.rs │ ├── _1428_leftmost_column_with_at_least_a_one.rs │ ├── _1429_first_unique_number.rs │ ├── _1430_chick_if_a_string_is_a_valid_sequence_from_root_to_leaves_path_in_a_binary_tree.rs │ ├── _1431_kids_with_the_greatest_number_of_candies.rs │ ├── _1432_max_difference_you_can_get_from_change_an_integer.rs │ ├── _1433_check_if_a_string_can_break_another_string.rs │ ├── _1436_destination_city.rs │ ├── _1437_check_if_all_1s_are_at_least_length_k_places_away.rs │ ├── _1438_longest_continuous_subarray_with_absolute_diff_less_than_or_equal_to_limit.rs │ ├── _1439_find_kth_smallest_sum_of_a_matrix_with_sorted_rows.rs │ ├── _1441_build_an_array_with_stack_operations.rs │ ├── _1442_count_triplets_that_can_form_two_arrays_of_equal_xor.rs │ ├── _1443_minimum_time_to_collect_all_apples_in_a_tree.rs │ ├── _1444_number_of_ways_of_cutting_a_pizza.rs │ ├── _1446_consecutive_characters.rs │ ├── _1447_simplified_fractions.rs │ ├── _1448_count_good_nodes_in_binary_tree.rs │ ├── _1450_number_of_students_doing_homework_at_a_given_time.rs │ ├── _1451_rearrange_words_in_a_sentence.rs │ ├── _1452_people_whose_list_of_favorite_companies_is_not_a_subset_of_another_list.rs │ ├── _1455_check_if_a_word_occurs_as_a_prefix_of_any_word_in_a_sentence.rs │ ├── _1456_maximum_number_of_vowels_in_a_substring_of_given_length.rs │ ├── _1457_pseudo_palindromic_paths_in_a_binary_tree.rs │ ├── _1458_max_dot_product_of_two_subsequences.rs │ ├── _1460_make_two_arrays_equal_by_reversing_sub_arrays.rs │ ├── _1461_check_if_a_string_contains_all_binary_codes_of_size_k.rs │ ├── _1462_course_schedule_4.rs │ ├── _1463_cherry_pickup_2.rs │ ├── _1464_maximum_product_of_two_elements_in_an_array.rs │ ├── _1465_maximum_area_of_a_piece_of_cake_after_horizontal_and_vertical_cuts.rs │ ├── _1466_reorder_routes_to_make_all_paths_lead_to_the_city_zero.rs │ ├── _1469_find_all_the_lonely_nodes.rs │ ├── _1470_shuffle_the_array.rs │ ├── _1471_the_k_strongest_values_in_an_array.rs │ ├── _1472_design_browser_history.rs │ ├── _1473_paint_house_3.rs │ ├── _1474_delete_n_nodes_after_m_nodes_of_a_linked_list.rs │ ├── _1475_final_prices_with_a_speial_discount_in_shop.rs │ ├── _1476_subrectangle_queries.rs │ ├── _1477_find_two_non_overlapping_sub_arrays_each_with_target_sum.rs │ ├── _1478_allocate_mailboxes.rs │ ├── _1480_running_sum_of_1d_array.rs │ ├── _1481_least_number_of_unique_integers_after_k_removals.rs │ ├── _1482_minimum_number_of_days_to_make_m_bouquets.rs │ ├── _1486_xor_operation_in_an_array.rs │ ├── _1487_making_file_names_unique.rs │ ├── _1488_avoid_flood_in_the_city.rs │ ├── _1489_find_critical_and_pseudo_critical_edges_in_minimum_spanning_tree.rs │ ├── _1491_average_salary_excluding_minimum_and_maximum_salary.rs │ ├── _1492_the_kth_factor_of_n.rs │ ├── _1493_longest_subarray_of_1s_after_deleting_one_element.rs │ ├── _1494_parallel_courses_2.rs │ ├── _1496_path_crossing.rs │ ├── _1497_check_if_array_pairs_are_divisible_by_k.rs │ ├── _1498_number_of_subsequences_that_satisfy_the_given_sum_condition.rs │ ├── _1499_max_value_of_equation.rs │ └── mod.rs │ ├── d15 │ ├── _1500_design_a_file_sharing_system.rs │ ├── _1502_can_make_arithmetic_progression_from_sequence.rs │ ├── _1503_last_moment_before_all_ants_fall_out_of_a_plank.rs │ ├── _1504_count_submatrices_with_all_ones.rs │ ├── _1507_reformat_date.rs │ ├── _1508_range_sum_of_sorted_subarray_sums.rs │ ├── _1509_minimum_difference_between_largest_and_smallest_value_in_three_moves.rs │ ├── _1510_stone_game_4.rs │ ├── _1512_number_of_good_pairs.rs │ ├── _1513_number_of_substrings_with_only_1s.rs │ ├── _1514_path_with_maximum_probability.rs │ ├── _1515_best_position_for_a_service_center.rs │ ├── _1518_water_bottles.rs │ ├── _1519_number_of_nodes_in_the_sub_tree_with_the_same_label.rs │ ├── _1520_maximum_number_of_non_overlapping_substrings.rs │ ├── _1521_find_a_value_of_mysterious_function_closest_to_target.rs │ ├── _1523_cound_odd_numbers_in_interval_range.rs │ ├── _1524_number_of_sub_arrays_with_odd_sum.rs │ ├── _1525_number_of_good_ways_to_split_a_string.rs │ ├── _1526_minimum_number_of_increments_on_subarrays_to_form_a_target_array.rs │ ├── _1528_shuffle_string.rs │ ├── _1529_bulb_switcher_5.rs │ ├── _1530_number_of_good_leaf_nodes_pairs.rs │ ├── _1531_string_compression_2.rs │ ├── _1533_find_the_index_of_the_large_integer.rs │ ├── _1534_count_good_triplets.rs │ ├── _1535_find_the_winner_of_an_array_game.rs │ ├── _1536_minimum_swaps_to_arrange_a_binary_grid.rs │ ├── _1537_get_the_maximum_score.rs │ ├── _1538_guess_the_majority_in_an_hidden_array.rs │ ├── _1539_kth_missing_positive_number.rs │ ├── _1540_can_convert_string_in_k_moves.rs │ ├── _1541_minimum_insertions_to_balance_a_parentheses_string.rs │ ├── _1542_find_longest_awesome_substring.rs │ ├── _1544_make_the_string_great.rs │ ├── _1545_find_kth_bit_in_nth_binary_stringrs.rs │ ├── _1546_maximum_number_of_non_overlapping_subarrays_with_sum_equals_target.rs │ ├── _1547_minimum_cost_to_cut_a_stick.rs │ ├── _1548_the_most_similar_path_in_a_graph.rs │ ├── _1550_three_consecutive_odds.rs │ ├── _1551_minimum_operations_to_make_array_equalrs.rs │ ├── _1552_magnetic_force_between_two_balls.rs │ ├── _1553_minimum_number_of_days_to_eat_n_oranges.rs │ ├── _1554_strings_differ_by_one_character.rs │ ├── _1556_thousand_separator.rs │ ├── _1557_minimum_number_of_vertices_to_reach_all_nodes.rs │ ├── _1558_minimum_numbers_of_function_calls_to_make_target_array.rs │ ├── _1559_detect_cycles_in_2d_grid.rs │ ├── _1560_most_visited_sector_in_a_circular_track.rs │ ├── _1561_maximum_number_of_coins_you_can_get.rs │ ├── _1562_find_latest_group_of_size_m.rs │ ├── _1563_stone_game_5.rs │ ├── _1564_pub_boxes_into_the_warehouse_1.rs │ ├── _1566_detect_pattern_of_length_m_repeated_k_or_more_times.rs │ ├── _1567_maximum_length_of_subarray_with_positive_product.rs │ ├── _1568_minimum_number_of_days_to_disconnect_island.rs │ ├── _1569_number_of_ways_to_reorder_array_to_get_same_bst.rs │ ├── _1570_dot_product_of_two_sparse_vectors.rs │ ├── _1572_matrix_diagonal_sum.rs │ ├── _1573_number_of_ways_to_split_a_string.rs │ ├── _1574_shortest_subarray_to_be_removed_to_make_array_sorted.rs │ ├── _1575_count_all_possible_routes.rs │ ├── _1576_replace_all_to_avoid_consecutive_repeating_characters.rs │ ├── _1577_number_of_ways_where_square_of_number_is_equal_to_product_of_two_numbers.rs │ ├── _1578_minimum_deleteion_cost_to_avoid_repeating_letters.rs │ ├── _1579_remove_max_number_of_edges_to_keep_graph_fully_traversable.rs │ ├── _1580_put_boxes_into_the_warehouse_2.rs │ ├── _1582_special_positions_in_a_binary_matrix.rs │ ├── _1583_count_unhappy_friends.rs │ ├── _1584_min_cost_to_connect_all_points.rs │ ├── _1585_check_if_string_is_transformable_with_substring_sort_operations.rs │ ├── _1586_binary_search_tree_iterator_2.rs │ ├── _1588_sum_of_all_odd_length_subarrays.rs │ ├── _1589_maximum_sum_obtained_of_any_permutation.rs │ ├── _1590_make_sum_divisible_by_p.rs │ ├── _1591_strange_printer_2.rs │ ├── _1592_rearrange_spaces_between_words.rs │ ├── _1593_split_a_string_into_the_max_number_of_unique_substrings.rs │ ├── _1594_maximum_non_negative_product_in_a_matrix.rs │ ├── _1595_minimum_cost_to_connect_two_groups_of_points.rs │ ├── _1598_crawler_log_folder.rs │ ├── _1599_maximum_profit_of_operating_a_centennial_wheel.rs │ └── mod.rs │ ├── d16 │ ├── _1600_throne_inheritance.rs │ ├── _1603_design_parking_system.rs │ ├── _1604_alart_using_same_key_card_three_or_more_times_in_a_one_hour_period.rs │ ├── _1605_find_valid_matrix_given_row_and_column_sums.rs │ ├── _1608_special_array_with_x_elements_greater_than_or_equal_x.rs │ ├── _1609_even_odd_tree.rs │ ├── _1611_minimum_one_bit_operations_to_make_integers_zero.rs │ ├── _1614_maximum_nesting_depth_of_the_parentheses.rs │ ├── _1615_maximal_network_rank.rs │ ├── _1616_split_two_strings_to_make_palindrome.rs │ ├── _1617_count_subtrees_with_max_distance_between_cities.rs │ ├── _1619_mean_of_array_after_removing_some_elements.rs │ ├── _1620_coordinate_with_maxium_network_quality.rs │ ├── _1621_number_of_sets_of_k_non_overlapping_line_segments.rs │ ├── _1624_largest_substring_between_two_equal_characters.rs │ ├── _1625_lexicographically_smaller_string_after_applying_operations.rs │ ├── _1626_best_team_with_no_conflicts.rs │ ├── _1627_graph_connectivity_with_threshold.rs │ ├── _1629_slowest_key.rs │ ├── _1630_arithmetic_subarrays.rs │ ├── _1631_path_with_minimum_effort.rs │ ├── _1636_sort_array_by_increasing_frequency.rs │ ├── _1637_widest_vertical_area_between_two_points_containing_no_points.rs │ ├── _1638_count_substrings_that_differ_by_one_characters.rs │ ├── _1640_check_array_formation_through_concatenation.rs │ ├── _1641_count_sorted_vowel_strings.rs │ ├── _1642_furthest_building_you_can_reach.rs │ ├── _1643_kth_smallest_instructions.rs │ ├── _1646_get_maximum_in_generated_array.rs │ ├── _1647_minimum_deletions_to_make_character_frequencies_unique.rs │ ├── _1648_sell_diminishing_valued_colored_balls.rs │ ├── _1652_defuse_the_bomb.rs │ ├── _1653_minimum_deletions_to_make_string_balanced.rs │ ├── _1654_minimum_jumps_to_reach_home.rs │ ├── _1656_design_an_ordered_stream.rs │ ├── _1657_determine_if_two_strings_are_close.rs │ ├── _1658_minimum_operations_to_reduce_x_to_zero.rs │ ├── _1659_maximize_grid_happiness.rs │ ├── _1662_check_if_two_string_arrays_are_equivalent.rs │ ├── _1663_smallest_string_with_a_given_numeric_value.rs │ ├── _1664_ways_to_make_a_fair_array.rs │ ├── _1665_minimum_initial_energy_to_finish_tasks.rs │ ├── _1668_maximum_repeating_substring.rs │ ├── _1669_merge_in_between_linked_lists.rs │ ├── _1670_design_front_middle_back_queue.rs │ ├── _1671_minimum_number_of_removals_to_make_mountain_array.rs │ ├── _1672_richest_customer_wealth.rs │ ├── _1673_find_the_most_competitive_subsequence.rs │ ├── _1674_minimum_moves_to_make_array_complementary.rs │ ├── _1678_goal_parser_interpretation.rs │ ├── _1679_max_number_of_k_sum_pairs.rs │ ├── _1680_concatenation_of_consecutive_binary_numbers.rs │ ├── _1681_minimum_incompatibility.rs │ ├── _1682_longest_palindromic_subsequence_2.rs │ ├── _1684_count_the_number_of_consistent_strings.rs │ ├── _1685_sum_of_absolute_differences_in_a_sorted_array.rs │ ├── _1686_stone_game_6.rs │ ├── _1688_count_of_matches_in_tournament.rs │ ├── _1689_partitioning_into_minimum_number_of_deci_binary_numbers.rs │ ├── _1690_stone_game_7.rs │ ├── _1691_maximum_height_by_stacking_cuboids.rs │ ├── _1692_count_ways_to_distribute_candies.rs │ ├── _1694_reformat_phone_number.rs │ ├── _1695_maximum_erasure_value.rs │ ├── _1696_jump_game_6.rs │ ├── _1697_checking_existence_of_edge_length_limited_paths.rs │ ├── _1698_number_of_distinct_substrings_in_a_string.rs │ └── mod.rs │ ├── d17 │ ├── _1700_number_of_students_unable_to_eat_lunch.rs │ ├── _1701_average_waiting_time.rs │ ├── _1702_maximum_binary_string_after_change.rs │ ├── _1704_determine_if_string_halves_are_alike.rs │ ├── _1705_maximum_number_of_eaten_apples.rs │ ├── _1706_where_will_the_ball_fall.rs │ ├── _1708_largest_subarray_length_k.rs │ ├── _1710_maximum_units_on_a_truck.rs │ ├── _1711_count_good_meals.rs │ ├── _1712_ways_to_split_array_into_three_subarrays.rs │ ├── _1713_minimum_operations_to_make_a_subsequence.rs │ ├── _1716_calculate_money_in_leetcode_bank.rs │ ├── _1717_maximum_score_from_removing_substrings.rs │ ├── _1718_construct_the_lexicographically_largest_valid_sequence.rs │ ├── _1720_decode_xored_array.rs │ ├── _1721_swapping_nodes_in_a_linked_list.rs │ ├── _1722_minimize_hamming_distance_after_swap_operations.rs │ ├── _1725_number_of_rectangles_that_can_form_the_largest_square.rs │ ├── _1726_tuple_with_same_product.rs │ ├── _1727_largest_submatrix_with_rearrangements.rs │ ├── _1730_shortest_path_to_get_food.rs │ ├── _1732_find_the_highest_altitude.rs │ ├── _1733_minimum_number_of_people_to_teach.rs │ ├── _1734_decode_xored_permutation.rs │ ├── _1736_latest_time_by_replacing_hidden_digits.rs │ ├── _1737_change_minimum_characters_to_satisfy_one_of_three_conditions.rs │ ├── _1738_find_kth_largest_xor_coordinate_value.rs │ ├── _1740_find_distance_in_a_binary_tree.rs │ ├── _1742_maximum_number_of_balls_in_a_box.rs │ ├── _1743_restore_the_array_from_adjacent_pairs.rs │ ├── _1744_can_you_eat_your_favorite_candy_on_your_favorite_day.rs │ ├── _1745_palindrome_partitioning_4.rs │ ├── _1746_maximum_subarray_sum_after_one_operation.rs │ ├── _1748_sum_of_unique_elements.rs │ ├── _1749_maximum_absolute_sum_of_any_subarray.rs │ ├── _1750_minimum_length_of_string_after_deleting_similar_ends.rs │ ├── _1752_check_if_array_is_sorted_and_rotated.rs │ ├── _1753_maximum_score_from_removing_stones.rs │ ├── _1754_largest_merge_of_two_strings.rs │ ├── _1758_minimum_changes_to_make_alternating_binary_string.rs │ ├── _1760_minimum_limit_of_balls_in_a_bag.rs │ ├── _1762_buildings_with_an_ocean_view.rs │ ├── _1769_minimum_number_of_operations_to_move_all_balls_to_each_box.rs │ ├── _1773_count_items_matching_a_rule.rs │ ├── _1779_find_nearest_point_that_has_the_same_x_or_y_coordinate.rs │ ├── _1784_check_if_binary_string_has_at_most_one_segment_of_ones.rs │ ├── _1790_check_if_one_string_swap_can_make_strings_equal.rs │ ├── _1791_find_center_of_star_graph.rs │ ├── _1792_maximum_average_pass_ratio.rs │ ├── _1794_count_pairs_of_equal_substrings_with_minimum_difference.rs │ ├── _1796_second_largest_digit_in_a_string.rs │ ├── _1797_design_authentication_manager.rs │ ├── _1798_maximum_number_of_consecutive_values_you_can_make.rs │ └── mod.rs │ ├── d18 │ ├── _1800_maximum_ascending_subarray_sum.rs │ ├── _1801_number_of_orders_in_the_backlog.rs │ ├── _1802_maximum_value_at_a_given_index_in_a_bounded_array.rs │ ├── _1804_implement_trie_2.rs │ ├── _1805_number_of_different_integers_in_a_string.rs │ ├── _1806_minimum_number_of_operations_to_reinitialize_a_permutation.rs │ ├── _1807_evaluate_the_bracket_pairs_of_a_string.rs │ ├── _1810_minimum_path_cost_in_a_hidden_grid.rs │ ├── _1812_determine_color_of_a_chessboard_square.rs │ ├── _1813_sentence_similarity_3.rs │ ├── _1814_count_nice_pairs_in_an_array.rs │ ├── _1816_truncate_sentence.rs │ ├── _1817_finding_the_users_active_minutes.rs │ ├── _1818_minimum_absolute_sum_difference.rs │ ├── _1820_maximum_number_of_accepted_invitations.rs │ ├── _1822_sign_of_the_product_of_an_array.rs │ ├── _1823_find_the_winner_of_the_circular_game.rs │ ├── _1824_minimum_sideway_jumps.rs │ ├── _1826_faulty_sensor.rs │ ├── _1827_minimum_operations_to_make_the_array_increasing.rs │ ├── _1828_queries_on_number_of_points_inside_a_circle.rs │ ├── _1829_maximum_xor_for_each_query.rs │ ├── _1832_check_if_the_sentence_is_pangram.rs │ ├── _1833_maximum_ice_cream_bars.rs │ ├── _1834_single_threaded_cpu.rs │ ├── _1836_remove_duplicates_from_an_unsorted_linked_list.rs │ ├── _1837_sum_of_digits_in_base_k.rs │ ├── _1838_frequency_of_the_most_frequent_element.rs │ ├── _1839_longest_substring_of_all_vowels_in_order.rs │ ├── _1844_replace_all_digits_with_characters.rs │ ├── _1848_minimum_distance_to_the_target_element.rs │ ├── _1854_maximum_population_year.rs │ ├── _1859_sorting_the_sentence.rs │ ├── _1863_sum_of_all_subset_xor_totals.rs │ ├── _1869_longer_contiguous_segments_of_ones_than_zeros.rs │ ├── _1876_substrings_of_size_three_with_distinct_characters.rs │ ├── _1880_check_if_word_equals_summation_of_two_words.rs │ ├── _1886_determine_whether_matrix_can_be_obtained_by_rotation.rs │ ├── _1893_check_if_all_the_integers_in_a_range_are_covered.rs │ ├── _1897_redistribute_characters_to_make_all_strings_equal.rs │ └── mod.rs │ ├── d19 │ ├── _1903_largest_odd_number_in_string.rs │ ├── _1909_remove_one_element_to_make_the_array_strictly_increasing.rs │ ├── _1913_maximum_product_difference_between_two_pairs.rs │ ├── _1920_build_array_from_permutation.rs │ ├── _1925_count_square_sum_triples.rs │ ├── _1929_concatenation_of_array.rs │ ├── _1933_check_if_string_is_decomposable_into_value_equal_substrings.rs │ ├── _1935_maximum_number_of_words_you_can_type.rs │ ├── _1941_check_if_all_characters_have_equal_number_of_occurrences.rs │ ├── _1945_sum_of_digits_of_string_after_convert.rs │ ├── _1952_three_divisors.rs │ ├── _1957_delete_characters_to_make_fancy_string.rs │ ├── _1961_check_if_string_is_a_prefix_of_array.rs │ ├── _1967_number_of_strings_that_appear_as_substrings_in_word.rs │ ├── _1971_find_if_path_exists_in_graph.rs │ ├── _1974_minimum_time_to_type_word_using_special_typewriter.rs │ ├── _1979_find_greatest_common_divisor_of_array.rs │ ├── _1984_minimum_difference_between_highest_and_lowest_of_k_scores.rs │ ├── _1991_find_the_middle_index_in_array.rs │ ├── _1995_count_special_quadruplets.rs │ └── mod.rs │ ├── d2 │ ├── _200_number_of_islands.rs │ ├── _201_bitwise_and_of_numbers_range.rs │ ├── _202_happy_number.rs │ ├── _203_remove_linked_list_elements.rs │ ├── _204_count_primes.rs │ ├── _205_isomorphic_strings.rs │ ├── _206_reverse_linked_list.rs │ ├── _207_course_schedule.rs │ ├── _208_implement_trie.rs │ ├── _209_minimum_size_subarray_sum.rs │ ├── _210_course_schedule_2.rs │ ├── _211_add_and_search_word_data_structure_design.rs │ ├── _212_word_search_2.rs │ ├── _213_house_robber_2.rs │ ├── _214_shortest_palindrome.rs │ ├── _215_kth_largest_element_in_an_array.rs │ ├── _216_combination_sum_3.rs │ ├── _217_contains_duplicate.rs │ ├── _218_the_skyline_problem.rs │ ├── _219_contains_duplicate_2.rs │ ├── _220_contains_duplicate_3.rs │ ├── _221_maximal_square.rs │ ├── _222_count_complete_tree_nodes.rs │ ├── _223_rectangle_area.rs │ ├── _224_basic_calculator.rs │ ├── _225_implement_stack_using_queues.rs │ ├── _226_invert_binary_tree.rs │ ├── _227_basic_calculator_2.rs │ ├── _228_summary_ranges.rs │ ├── _229_majority_element_2.rs │ ├── _230_kth_smallest_element_in_a_bst.rs │ ├── _231_power_of_two.rs │ ├── _232_implent_queue_using_stacks.rs │ ├── _233_number_of_digit_one.rs │ ├── _234_palindrome_linked_list.rs │ ├── _235_lowest_common_ancestor_of_a_binary_search_tree.rs │ ├── _236_lowest_common_ancestor_of_a_binary_tree.rs │ ├── _238_product_of_array_except_self.rs │ ├── _239_sliding_window_maximum.rs │ ├── _240_search_a_2d_matrix_2.rs │ ├── _241_different_ways_to_add_parentheses.rs │ ├── _242_valid_anagram.rs │ ├── _243_shortest_word_distance.rs │ ├── _244_shortest_word_distance_2.rs │ ├── _245_shortest_word_distance_3.rs │ ├── _246_strobogrammantic_number.rs │ ├── _247_strobogrammatic_number_2.rs │ ├── _248_strobogrammatic_number_3.rs │ ├── _249_group_shifted_strings.rs │ ├── _250_count_univalue_subtrees.rs │ ├── _251_flatten_2d_vector.rs │ ├── _252_meeting_rooms.rs │ ├── _253_meeting_rooms_2.rs │ ├── _254_factor_combinations.rs │ ├── _255_verify_preorder_sequence_in_binary_search_tree.rs │ ├── _256_paint_house.rs │ ├── _257_binary_tree_paths.rs │ ├── _258_add_digits.rs │ ├── _259_3sum_smaller.rs │ ├── _260_single_number_3.rs │ ├── _261_graph_valid_tree.rs │ ├── _263_ugly_number.rs │ ├── _264_ugly_number_2.rs │ ├── _265_paint_house_2.rs │ ├── _266_palindrome_permutation.rs │ ├── _267_palindrome_permutation_2.rs │ ├── _268_missing_number.rs │ ├── _269_alien_dictionary.rs │ ├── _270_closest_binary_search_tree_value.rs │ ├── _271_encode_and_decode_strings.rs │ ├── _272_closest_binary_search_tree_value_2.rs │ ├── _273_integer_to_english_words.rs │ ├── _274_h_index.rs │ ├── _275_h_index_2.rs │ ├── _276_paint_fence.rs │ ├── _277_find_the_celebrity.rs │ ├── _278_first_bad_version.rs │ ├── _279_perfect_squares.rs │ ├── _280_wiggle_sort.rs │ ├── _281_zigzag_iterator.rs │ ├── _282_expression_add_operators.rs │ ├── _283_move_zeros.rs │ ├── _285_inorder_successor_in_bst.rs │ ├── _286_walls_and_gates.rs │ ├── _287_find_the_duplicate_number.rs │ ├── _288_unique_word_abbreviation.rs │ ├── _289_game_of_life.rs │ ├── _290_word_pattern.rs │ ├── _291_word_pattern_2.rs │ ├── _292_nim_game.rs │ ├── _293_flip_game.rs │ ├── _294_flip_game_2.rs │ ├── _295_find_median_from_data_stream.rs │ ├── _296_best_meeting_point.rs │ ├── _297_serialize_and_deserialize_binary_tree.rs │ ├── _298_binary_tree_longest_consecutive_sequence.rs │ ├── _299_bulls_and_cows.rs │ └── mod.rs │ ├── d20 │ ├── _2000_reverse_prefix_of_word.rs │ ├── _2006_count_number_of_pairs_with_absolute_difference_k.rs │ ├── _2011_final_value_of_variable_after_performing_operations.rs │ ├── _2016_maximum_difference_between_increasing_elements.rs │ ├── _2022_convert_1d_array_into_2d_array.rs │ ├── _2027_minimum_moves_to_convert_string.rs │ ├── _2032_two_out_of_three.rs │ ├── _2037_minimum_number_of_moves_to_seat_everyone.rs │ ├── _2042_check_if_numbers_are_ascending_in_a_sentence.rs │ ├── _2047_number_of_valid_words_in_a_sentence.rs │ ├── _2053_kth_distinct_string_in_an_array.rs │ ├── _2057_smallest_index_with_equal_value.rs │ ├── _2062_count_vowel_substrings_of_a_string.rs │ ├── _2068_check_whether_two_strings_are_almost_equivalent.rs │ ├── _2073_time_needed_to_buy_tickets.rs │ ├── _2085_count_common_words_with_one_occurrence.rs │ ├── _2089_find_target_indices_after_sorting_array.rs │ ├── _2094_finding_3_digit_even_numbers.rs │ ├── _2099_find_subsequence_of_length_k_with_the_largest_sum.rs │ └── mod.rs │ ├── d21 │ ├── _2103_rings_and_rods.rs │ ├── _2108_find_first_palindromic_string_in_the_array.rs │ ├── _2114_maximum_number_of_words_found_in_sentences.rs │ ├── _2119_a_number_after_a_double_reversal.rs │ ├── _2124_check_if_all_a_s_appears_before_all_b_s.rs │ ├── _2129_capitalize_the_title.rs │ ├── _2133_check_if_every_row_and_column_contains_all_numbers.rs │ ├── _2138_divide_a_string_into_groups_of_size_k.rs │ ├── _2144_minimum_cost_of_buying_candies_with_discount.rs │ ├── _2148_count_elements_with_strictly_smaller_and_greater_elements.rs │ └── mod.rs │ ├── d3 │ ├── _300_longest_increasing_subsequence.rs │ ├── _301_remove_invalid_parentheses.rs │ ├── _302_smallest_rectangle_enclosing_black_pixels.rs │ ├── _303_range_sum_query.rs │ ├── _304_range_sum_query_2d_immutable.rs │ ├── _305_number_of_islands_2.rs │ ├── _306_additive_number.rs │ ├── _307_range_sum_query_mutable.rs │ ├── _309_best_time_to_buy_and_sell_stock_with_cooldown.rs │ ├── _310_minimum_height_trees.rs │ ├── _311_sparse_matrix_multiplication.rs │ ├── _312_burst_balloons.rs │ ├── _313_super_ugly_number.rs │ ├── _314_binary_tree_vertical_order_traversal.rs │ ├── _315_count_of_smaller_numbers_after_self.rs │ ├── _316_remove_duplicate_letters.rs │ ├── _317_shortest_distance_from_all_buildings.rs │ ├── _318_maximum_product_of_word_lengths.rs │ ├── _319_bulb_switcher.rs │ ├── _320_generalized_abbreviation.rs │ ├── _321_create_maximum_number.rs │ ├── _322_coin_change.rs │ ├── _323_number_of_connected_components_in_an_unditected_graph.rs │ ├── _324_wiggle_sort_2.rs │ ├── _325_maximum_size_subarray_sum_equals_k.rs │ ├── _326_power_of_three.rs │ ├── _328_odd_even_linked_list.rs │ ├── _329_longest_increasing_path_in_a_matrix.rs │ ├── _330_patching_array.rs │ ├── _331_verify_preorder_serialization_of_a_binary_tree.rs │ ├── _332_reconstruct_itinerary.rs │ ├── _333_largest_bst_subtree.rs │ ├── _334_increasing_triplet_subsequence.rs │ ├── _336_palindrome_pairs.rs │ ├── _337_house_robber_3.rs │ ├── _338_counting_bits.rs │ ├── _339_nested_list_weight_sum.rs │ ├── _340_longest_substring_with_at_most_k_distinct_characters.rs │ ├── _341_flatten_nested_list_iterator.rs │ ├── _342_power_of_four.rs │ ├── _343_integer_break.rs │ ├── _344_reverse_string.rs │ ├── _345_reverse_vowels_of_a_string.rs │ ├── _346_moving_average_from_data_stream.rs │ ├── _347_top_k_frequent_elements.rs │ ├── _348_design_tic_tac_toe.rs │ ├── _349_intersection_of_two_arrays.rs │ ├── _350_intersection_of_two_arrays_2.rs │ ├── _351_android_unlock_patterns.rs │ ├── _352_data_stream_as_disjoint_intervals.rs │ ├── _353_design_snake_game.rs │ ├── _354_russian_doll_envelopes.rs │ ├── _355_design_twitter.rs │ ├── _356_line_reflection.rs │ ├── _357_count_numbers_with_unique_digits.rs │ ├── _358_rearrange_string_k_distance_apart.rs │ ├── _359_logger_rate_limiter.rs │ ├── _360_sort_transformed_array.rs │ ├── _361_bomb_enemy.rs │ ├── _362_design_hit_counter.rs │ ├── _363_max_sum_of_rectangle_no_larger_than_k.rs │ ├── _364_nested_list_weight_sum_2.rs │ ├── _365_water_and_jug_problem.rs │ ├── _366_find_leaves_of_binary_tree.rs │ ├── _367_valid_perfect_square.rs │ ├── _368_largest_divisible_subset.rs │ ├── _369_plus_one_linked_list.rs │ ├── _370_range_addition.rs │ ├── _371_sum_of_two_integers.rs │ ├── _372_super_pow.rs │ ├── _373_find_k_pairs_with_smallest_sums.rs │ ├── _374_guess_number_higher_or_lower.rs │ ├── _375_guess_number_higher_or_lower_2.rs │ ├── _376_wiggle_subsequence.rs │ ├── _377_combination_sum_4.rs │ ├── _378_kth_smallest_element_in_a_sorted_matrix.rs │ ├── _379_design_phone_directory.rs │ ├── _380_insert_delete_get_random_o1.rs │ ├── _381_insert_delete_get_random_o1_duplicate_allowed.rs │ ├── _382_linked_list_random_node.rs │ ├── _383_ransom_note.rs │ ├── _384_shuffle_an_array.rs │ ├── _385_mini_parser.rs │ ├── _386_lexicographical_numbers.rs │ ├── _387_first_unique_character_in_a_string.rs │ ├── _388_longest_absolute_file_path.rs │ ├── _389_find_the_difference.rs │ ├── _390_elimination_game.rs │ ├── _391_perfect_rectangle.rs │ ├── _392_is_subsequence.rs │ ├── _393_utf8_validation.rs │ ├── _394_decode_string.rs │ ├── _395_longest_substring_with_at_least_k_repeating_characters.rs │ ├── _396_rotate_function.rs │ ├── _397_integer_replacement.rs │ ├── _398_random_pick_index.rs │ ├── _399_evaluate_division.rs │ └── mod.rs │ ├── d4 │ ├── _400_nth_digit.rs │ ├── _401_binary_watch.rs │ ├── _402_remove_k_digits.rs │ ├── _403_frog_jump.rs │ ├── _404_sum_of_left_leaves.rs │ ├── _405_convert_a_number_to_hexadecimal.rs │ ├── _406_queue_reconstruction_by_height.rs │ ├── _407_trapping_rain_water_2.rs │ ├── _408_valid_word_abbreviation.rs │ ├── _409_longest_palindrome.rs │ ├── _410_split_array_largest_sum.rs │ ├── _411_minimum_unique_word_abbreviation.rs │ ├── _412_fizz_buzz.rs │ ├── _413_arithmetic_slices.rs │ ├── _414_third_maximum_number.rs │ ├── _415_add_strings.rs │ ├── _416_partition_equal_subset_sum.rs │ ├── _417_pacific_atlantic_water_flow.rs │ ├── _418_sentence_screen_fitting.rs │ ├── _419_battleships_in_a_board.rs │ ├── _420_strong_password_checker.rs │ ├── _421_maximum_xor_of_two_numbers_in_an_array.rs │ ├── _422_valid_word_square.rs │ ├── _423_reconstruct_original_digits_from_english.rs │ ├── _424_longest_repeating_character_replacement.rs │ ├── _425_word_squares.rs │ ├── _432_all_o_one_data_structure.rs │ ├── _433_minimum_genetic_mutation.rs │ ├── _434_number_of_segments_in_a_string.rs │ ├── _435_non_overlapping_intervals.rs │ ├── _436_find_right_interval.rs │ ├── _437_path_sum_3.rs │ ├── _438_find_all_anagrams_in_a_string.rs │ ├── _439_ternary_expression_parser.rs │ ├── _440_k_th_smallest_in_lexicographical_order.rs │ ├── _441_arranging_coins.rs │ ├── _442_find_all_duplicates_in_an_array.rs │ ├── _443_string_compression.rs │ ├── _444_sequence_reconstruction.rs │ ├── _445_add_two_numbers_2.rs │ ├── _446_arithmetic_slices_2_subsequence.rs │ ├── _447_number_of_boomerangs.rs │ ├── _448_find_all_numbers_disappeared_in_an_array.rs │ ├── _449_serialize_and_deserialize_bst.rs │ ├── _450_delete_node_in_a_bst.rs │ ├── _451_sort_characters_by_frequency.rs │ ├── _452_minimum_number_of_arrows_to_burst_ballons.rs │ ├── _453_minimum_moves_to_equal_array_elements.rs │ ├── _454_4sum_2.rs │ ├── _455_assign_cookies.rs │ ├── _456_132_pattern.rs │ ├── _457_circular_array_loop.rs │ ├── _458_poor_pigs.rs │ ├── _459_repeated_substring_pattern.rs │ ├── _460_lfu_cache.rs │ ├── _461_hamming_distance.rs │ ├── _462_minimum_moves_to_equal_array_elements_2.rs │ ├── _463_island_perimeter.rs │ ├── _464_can_i_win.rs │ ├── _465_optimal_account_balancing.rs │ ├── _467_unique_substrings_in_wraparound_string.rs │ ├── _468_validate_ip_address.rs │ ├── _469_convex_polygon.rs │ ├── _470_implement_rand10_using_rand7.rs │ ├── _471_encode_string_with_shortest_length.rs │ ├── _472_concatenated_words.rs │ ├── _473_matchsticks_to_square.rs │ ├── _474_ones_and_zeroes.rs │ ├── _475_heaters.rs │ ├── _476_number_complement.rs │ ├── _477_total_hamming_distance.rs │ ├── _478_generate_random_point_in_circle.rs │ ├── _479_largest_palindrome_product.rs │ ├── _480_sliding_window_median.rs │ ├── _481_magical_string.rs │ ├── _482_license_key_formatting.rs │ ├── _484_find_permutation.rs │ ├── _485_max_consecutive_ones.rs │ ├── _486_predict_the_winner.rs │ ├── _487_max_consecutive_ones_2.rs │ ├── _488_zuma_game.rs │ ├── _490_the_maze.rs │ ├── _491_increasing_subsequences.rs │ ├── _492_construct_the_rectangle.rs │ ├── _493_reverse_pairs.rs │ ├── _494_target_sum.rs │ ├── _495_teemo_attacking.rs │ ├── _496_next_greater_element_1.rs │ ├── _497_random_point_in_nonoverlapping_rectangles.rs │ ├── _498_diagonal_traverse.rs │ ├── _499_the_maze_3.rs │ └── mod.rs │ ├── d5 │ ├── _500_keyboard_row.rs │ ├── _501_find_mode_in_binary_search_tree.rs │ ├── _502_ipo.rs │ ├── _503_next_greater_element_2.rs │ ├── _504_base_7.rs │ ├── _505_the_maze_2.rs │ ├── _506_relative_ranks.rs │ ├── _507_perfect_number.rs │ ├── _508_most_frequent_subtree_sum.rs │ ├── _509_fibonacci_number.rs │ ├── _513_find_bottom_left_tree_value.rs │ ├── _514_freedom_trail.rs │ ├── _515_find_largest_value_in_each_row.rs │ ├── _516_longest_palindromic_subsequence.rs │ ├── _517_super_washing_machines.rs │ ├── _518_coin_change_2.rs │ ├── _519_random_flip_matrix.rs │ ├── _520_detect_captial.rs │ ├── _521_longest_uncommon_subsequence_1.rs │ ├── _522_longest_uncommon_subsequence_2.rs │ ├── _523_continuous_subarray_sum.rs │ ├── _524_longest_word_in_dictionary_through_deleting.rs │ ├── _525_contiguous_array.rs │ ├── _526_beautiful_arrangment.rs │ ├── _527_word_abbreviation.rs │ ├── _528_random_pick_with_weight.rs │ ├── _529_minesweeper.rs │ ├── _530_minimum_absolute_difference_in_bst.rs │ ├── _531_lonely_pixel_1.rs │ ├── _532_k_diff_pairs_in_an_array.rs │ ├── _533_lonely_pixel_2.rs │ ├── _535_encode_and_decode_tiny_url.rs │ ├── _536_construct_binary_tree_from_string.rs │ ├── _537_complex_number_multiplication.rs │ ├── _538_convert_bst_to_greater_tree.rs │ ├── _539_minimum_time_difference.rs │ ├── _540_single_element_in_a_sorted_array.rs │ ├── _541_reverse_string_2.rs │ ├── _542_01_matrix.rs │ ├── _543_diameter_of_binary_tree.rs │ ├── _544_output_contest_matches.rs │ ├── _545_boundary_of_binary_tree.rs │ ├── _546_remove_boxes.rs │ ├── _547_friend_circles.rs │ ├── _548_split_array_with_equal_sum.rs │ ├── _549_binary_tree_longest_consecutive_sequence_2.rs │ ├── _551_student_attendance_record_1.rs │ ├── _552_student_attendance_record_2.rs │ ├── _553_optimal_division.rs │ ├── _554_brick_wall.rs │ ├── _555_split_concatenated_strings.rs │ ├── _556_next_greater_element_3.rs │ ├── _557_reverse_words_in_a_string_3.rs │ ├── _560_subarray_sum_equals_k.rs │ ├── _561_array_partition_1.rs │ ├── _562_longest_line_of_consecutive_one_in_matrix.rs │ ├── _563_binary_tree_tilt.rs │ ├── _564_find_the_closest_palindrome.rs │ ├── _565_array_nesting.rs │ ├── _566_reshape_the_matrix.rs │ ├── _567_permutation_in_string.rs │ ├── _568_maximum_vacation_days.rs │ ├── _572_subtree_of_another_tree.rs │ ├── _573_squirrel_simulation.rs │ ├── _575_distribute_candies.rs │ ├── _576_out_of_boundary_paths.rs │ ├── _581_shortest_unsorted_continuous_subarray.rs │ ├── _582_kill_process.rs │ ├── _583_delete_operation_for_two_strings.rs │ ├── _588_design_in_memory_file_system.rs │ ├── _591_tag_validator.rs │ ├── _592_fraction_addition_and_subtraction.rs │ ├── _593_valid_square.rs │ ├── _594_longest_harmonious_subsequence.rs │ ├── _598_range_addition_2.rs │ ├── _599_minimum_index_sum_of_two_lists.rs │ └── mod.rs │ ├── d6 │ ├── _604_design_compressed_string_iterator.rs │ ├── _605_can_place_flowers.rs │ ├── _606_construct_string_from_binary_tree.rs │ ├── _609_find_duplicate_file_in_system.rs │ ├── _611_valid_triangle_number.rs │ ├── _616_add_bold_tag_in_string.rs │ ├── _617_merge_two_binary_trees.rs │ ├── _621_task_scheduler.rs │ ├── _622_design_circular_queue.rs │ ├── _623_add_one_row_to_tree.rs │ ├── _624_maximum_distance_in_arrays.rs │ ├── _625_minimum_factorization.rs │ ├── _628_maximum_product_of_three_numbers.rs │ ├── _630_course_schedule_3.rs │ ├── _631_design_excel_sum_formula.rs │ ├── _632_smallest_range_covering_elements_from_k_lists.rs │ ├── _633_sum_of_square_numbers.rs │ ├── _634_find_the_derangement_of_an_array.rs │ ├── _635_design_log_storage_system.rs │ ├── _636_exclusive_time_of_functions.rs │ ├── _637_average_of_levels_in_binary_tree.rs │ ├── _638_shopping_offers.rs │ ├── _640_solve_the_equation.rs │ ├── _641_design_circular_deque.rs │ ├── _642_design_search_autocomplete_system.rs │ ├── _643_maximum_average_subarray_1.rs │ ├── _645_set_mismatch.rs │ ├── _646_maximum_length_of_pair_chain.rs │ ├── _647_palindromic_substrings.rs │ ├── _648_replace_words.rs │ ├── _649_dota2_senate.rs │ ├── _650_2_keys_keyboard.rs │ ├── _651_4_keys_keyboard.rs │ ├── _652_find_duplicate_subtrees.rs │ ├── _653_two_sum_4.rs │ ├── _654_maximum_binary_tree.rs │ ├── _655_print_binary_tree.rs │ ├── _657_robot_return_to_origin.rs │ ├── _658_find_k_cloest_elements.rs │ ├── _659_split_array_into_consecutive_subsequences.rs │ ├── _660_remove_9.rs │ ├── _661_image_smoother.rs │ ├── _662_maximum_width_of_binary_tree.rs │ ├── _663_equal_tree_partition.rs │ ├── _665_non_decreasing_array.rs │ ├── _666_path_sum_4.rs │ ├── _667_beautiful_arrangement_2.rs │ ├── _668_kth_smallest_number_in_multiplication.rs │ ├── _669_trim_a_binary_search_tree.rs │ ├── _670_maximum_swap.rs │ ├── _671_second_minimum_node_in_a_binary_tree.rs │ ├── _672_bulb_switcher_2.rs │ ├── _673_number_of_longest_increasing_subsequence.rs │ ├── _674_longest_continuous_increasing_subsequence.rs │ ├── _675_cut_off_trees_for_golf_event.rs │ ├── _676_implement_magic_dictionary.rs │ ├── _677_map_sum_pairs.rs │ ├── _678_valid_parenthesis_string.rs │ ├── _679_24_game.rs │ ├── _680_valid_palindrome_2.rs │ ├── _681_next_closest_time.rs │ ├── _682_baseball_game.rs │ ├── _683_k_empty_slots.rs │ ├── _684_redundant_connection.rs │ ├── _686_repeated_string_match.rs │ ├── _687_longest_univalue_path.rs │ ├── _688_knight_probability_in_chessboard.rs │ ├── _689_maximum_sum_of_3_non_overlapping_subarrays.rs │ ├── _692_top_k_frequent_words.rs │ ├── _693_binary_number_with_alternating_bits.rs │ ├── _694_number_of_distinct_islands.rs │ ├── _695_max_area_of_island.rs │ ├── _696_count_binary_substrings.rs │ ├── _697_degree_of_an_array.rs │ ├── _698_partition_to_k_equal_sum_subsets.rs │ └── mod.rs │ ├── d7 │ ├── _700_search_in_a_binary_search_tree.rs │ ├── _701_insert_into_a_binary_search_tree.rs │ ├── _703_kth_largest_element_in_a_stream.rs │ ├── _704_binary_search.rs │ ├── _705_design_hash_set.rs │ ├── _706_design_hash_map.rs │ ├── _707_design_linked_list.rs │ ├── _709_to_lower_case.rs │ ├── _710_random_pick_with_blacklist.rs │ ├── _712_minimum_ascii_delete_sum_for_two_string.rs │ ├── _713_subarray_product_less_than_k.rs │ ├── _714_best_time_to_buy_and_sell_stock_with_transaction_fee.rs │ ├── _716_max_stack.rs │ ├── _717_1bit_and_2bit_characters.rs │ ├── _718_maximum_length_of_repeated_subarray.rs │ ├── _719_find_kth_smallest_pair_distance.rs │ ├── _720_longest_word_in_dictionary.rs │ ├── _721_accounts_merge.rs │ ├── _722_remove_comments.rs │ ├── _723_candy_crush.rs │ ├── _724_find_pivot_index.rs │ ├── _725_split_linked_list_in_parts.rs │ ├── _726_number_of_atoms.rs │ ├── _727_minimum_window_subsequence.rs │ ├── _728_self_dividing_numbers.rs │ ├── _729_my_calendar_1.rs │ ├── _731_my_calendar_2.rs │ ├── _732_my_calendar_3.rs │ ├── _733_flood_fill.rs │ ├── _734_sentence_similarity.rs │ ├── _735_asteroid_collision.rs │ ├── _736_parse_lisp_expression.rs │ ├── _737_sentence_similarity_2.rs │ ├── _738_monotone_increasing_digits.rs │ ├── _739_daily_temperatures.rs │ ├── _740_delete_and_earn.rs │ ├── _742_closest_leaf_in_binary_tree.rs │ ├── _743_network_delay_time.rs │ ├── _744_find_smallest_letter_greater_than_target.rs │ ├── _746_min_cost_climbing_stairs.rs │ ├── _747_largest_number_at_least_twice_of_others.rs │ ├── _748_shortest_completing_word.rs │ ├── _750_number_of_corner_rectangles.rs │ ├── _751_ip_to_cidr.rs │ ├── _752_open_the_lock.rs │ ├── _753_cracking_the_safe.rs │ ├── _754_reach_a_number.rs │ ├── _755_pour_water.rs │ ├── _756_pyramid_transition_matrix.rs │ ├── _758_bold_words_in_string.rs │ ├── _760_find_anagram_mappings.rs │ ├── _761_special_binary_string.rs │ ├── _762_prime_number_of_set_bits_in_binary_representation.rs │ ├── _763_partition_labels.rs │ ├── _764_largest_plus_sign.rs │ ├── _765_couples_holding_hands.rs │ ├── _766_toeplitiz_matrix.rs │ ├── _767_reorganize_string.rs │ ├── _768_max_chunks_to_make_sorted_2.rs │ ├── _769_max_chunks_to_make_sorted.rs │ ├── _770_basic_calculator_4.rs │ ├── _771_jewels_and_stones.rs │ ├── _772_basic_calculator_3.rs │ ├── _773_sliding_puzzle.rs │ ├── _774_minimize_max_distance_to_gas_station.rs │ ├── _775_global_and_local_inversions.rs │ ├── _776_split_bst.rs │ ├── _777_swap_adjacent_in_lr_string.rs │ ├── _778_swim_in_rising_water.rs │ ├── _779_kth_symbol_in_grammar.rs │ ├── _780_reaching_points.rs │ ├── _781_rabbits_in_forest.rs │ ├── _783_minimum_distance_between_bst_nodes.rs │ ├── _784_letter_case_permutation.rs │ ├── _785_is_graph_bipartite.rs │ ├── _786_kth_smallest_prime_faction.rs │ ├── _787_cheapest_flights_within_k_stops.rs │ ├── _788_rotated_digits.rs │ ├── _789_escape_the_ghosts.rs │ ├── _790_domino_and_tromino_tiling.rs │ ├── _791_custom_sort_string.rs │ ├── _792_number_of_matching_subsequences.rs │ ├── _794_valid_tic_tac_toe_state.rs │ ├── _795_number_of_subarrays_with_bounded_maximum.rs │ ├── _796_rotate_string.rs │ ├── _797_all_paths_from_source_to_target.rs │ ├── _799_champagne_tower.rs │ └── mod.rs │ ├── d8 │ ├── _800_similar_rgb_color.rs │ ├── _801_minimum_swaps_to_make_sequences_increasing.rs │ ├── _802_find_eventual_safe_states.rs │ ├── _804_unique_morse_code_words.rs │ ├── _805_split_array_with_same_average.rs │ ├── _806_number_of_lines_to_write_string.rs │ ├── _807_max_increase_to_keep_city_skyline.rs │ ├── _808_soup_servings.rs │ ├── _809_expressive_words.rs │ ├── _810_chalkboard_xor_game.rs │ ├── _811_subdomain_visit_count.rs │ ├── _812_largest_triangle_area.rs │ ├── _813_largest_sum_of_averages.rs │ ├── _814_binary_tree_pruning.rs │ ├── _815_bus_routes.rs │ ├── _816_ambiguous_coordinates.rs │ ├── _817_linked_list_components.rs │ ├── _818_race_car.rs │ ├── _819_most_common_word.rs │ ├── _820_short_encoding_of_words.rs │ ├── _821_shortest_distance_to_a_character.rs │ ├── _822_card_flipping_game.rs │ ├── _823_binary_trees_with_factors.rs │ ├── _824_goat_latin.rs │ ├── _825_friends_of_appropriate_ages.rs │ ├── _826_most_profix_assigning_work.rs │ ├── _827_making_a_large_island.rs │ ├── _828_count_unique_characters_of_a_given_string.rs │ ├── _829_consecutive_numbers_sum.rs │ ├── _830_positions_of_large_groups.rs │ ├── _831_masking_personal_information.rs │ ├── _832_flipping_an_image.rs │ ├── _833_find_and_replace_in_string.rs │ ├── _835_image_overlap.rs │ ├── _836_rectangle_overlap.rs │ ├── _837_new_21_game.rs │ ├── _838_push_dominoes.rs │ ├── _840_magic_squares_in_grid.rs │ ├── _841_keys_and_rooms.rs │ ├── _842_split_array_into_fibonacci_sequence.rs │ ├── _843_guess_the_word.rs │ ├── _844_backspace_string_compare.rs │ ├── _845_longest_mountain_in_array.rs │ ├── _846_hand_of_straights.rs │ ├── _847_shortest_path_visiting_all_nodes.rs │ ├── _848_shifting_letters.rs │ ├── _849_maximize_distance_to_closest_person.rs │ ├── _851_loud_and_rich.rs │ ├── _852_peak_index_in_a_mountain_array.rs │ ├── _853_car_fleet.rs │ ├── _854_k_similar_strings.rs │ ├── _855_exam_room.rs │ ├── _856_score_of_parentheses.rs │ ├── _857_minimum_cost_to_hire_k_workers.rs │ ├── _858_mirror_reflection.rs │ ├── _859_buddy_strings.rs │ ├── _860_lemonade_change.rs │ ├── _861_score_after_flipping_matrix.rs │ ├── _862_shortest_subarray_with_sum_at_least_k.rs │ ├── _863_all_nodes_distance_k_in_binary_tree.rs │ ├── _865_smallest_subtree_with_all_the_deepest_nodes.rs │ ├── _866_prime_palindrome.rs │ ├── _867_transpose_matrix.rs │ ├── _868_binary_gap.rs │ ├── _869_reordered_power_of_2.rs │ ├── _870_advantage_shuffle.rs │ ├── _871_minimum_number_of_refueling_stops.rs │ ├── _872_leaf_similar_trees.rs │ ├── _873_length_of_longest_fibonacci_subsequence.rs │ ├── _874_walking_robot_simulation.rs │ ├── _875_koko_eating_bananas.rs │ ├── _876_middle_of_the_linked_list.rs │ ├── _877_stone_game.rs │ ├── _880_decoded_string_at_index.rs │ ├── _881_boats_to_save_people.rs │ ├── _883_projection_area_of_3d_shapes.rs │ ├── _884_uncommon_words_from_two_sentences.rs │ ├── _885_spiral_matrix_3.rs │ ├── _886_possible_bipartition.rs │ ├── _888_fair_candy_swap.rs │ ├── _889_construct_binary_tree_from_preorder_and_postorder_traversal.rs │ ├── _890_find_and_replace_pattern.rs │ ├── _891_sum_of_subsequence_widths.rs │ ├── _892_surface_area_of_3d_shapes.rs │ ├── _893_groups_of_special_equivalent_string.rs │ ├── _894_all_possible_full_binary_trees.rs │ ├── _895_maximum_frequency_stack.rs │ ├── _896_monotonic_array.rs │ ├── _897_increasing_order_search_tree.rs │ ├── _898_bitwise_ors_of_subarrays.rs │ ├── _899_orderly_queue.rs │ └── mod.rs │ ├── d9 │ ├── _900_rle_iterator.rs │ ├── _901_online_stock_span.rs │ ├── _903_valid_permutations_for_di_sequence.rs │ ├── _904_fruit_into_baskets.rs │ ├── _905_sort_array_by_parity.rs │ ├── _907_sum_of_subarray_minimums.rs │ ├── _908_smallest_range_1.rs │ ├── _909_snakes_and_ladders.rs │ ├── _910_smallest_range_2.rs │ ├── _911_online_election.rs │ ├── _912_sort_an_array.rs │ ├── _914_x_of_a_kind_in_a_deck_of_cards.rs │ ├── _915_partition_array_into_disjoint_intervals.rs │ ├── _916_word_subsets.rs │ ├── _917_reverse_only_letters.rs │ ├── _918_maximum_sum_circular_subarray.rs │ ├── _919_complete_binary_tree_inserter.rs │ ├── _921_minimum_add_to_make_parentheses_valid.rs │ ├── _922_sort_array_by_parity_2.rs │ ├── _923_3sum_with_multiplicity.rs │ ├── _924_minimize_malware_spread.rs │ ├── _925_long_pressed_name.rs │ ├── _926_flip_string_to_monotone_increasing.rs │ ├── _929_unique_email_addresses.rs │ ├── _930_binary_subarrays_with_sum.rs │ ├── _931_minimum_falling_path_sum.rs │ ├── _932_beautiful_array.rs │ ├── _933_number_of_recent_calls.rs │ ├── _934_shortest_bridge.rs │ ├── _935_knight_dialer.rs │ ├── _937_reorder_log_files.rs │ ├── _938_range_sum_of_bst.rs │ ├── _939_minimum_area_rectangle.rs │ ├── _941_valid_mountain_array.rs │ ├── _942_di_string_match.rs │ ├── _944_delete_columns_to_make_sorted.rs │ ├── _945_minimum_increment_to_make_array_unique.rs │ ├── _946_validate_stack_sequences.rs │ ├── _947_most_stones_removed_with_same_row_or_column.rs │ ├── _948_bag_of_tokens.rs │ ├── _949_largest_time_for_given_digits.rs │ ├── _950_reveal_cards_in_increasing_order.rs │ ├── _951_flip_equivalent_binary_trees.rs │ ├── _953_verifying_an_alien_dictionary.rs │ ├── _954_array_of_doubled_pairs.rs │ ├── _955_delete_columns_to_make_sorted_2.rs │ ├── _957_prison_cells_after_n_days.rs │ ├── _958_check_completeness_of_a_binary_tree.rs │ ├── _959_regions_cut_by_slashes.rs │ ├── _960_delete_columns_to_make_sorted_3.rs │ ├── _961_n_repeated_element_in_size_2n_array.rs │ ├── _962_maximum_with_ramp.rs │ ├── _963_minimum_area_rectangle_2.rs │ ├── _965_univalued_binary_tree.rs │ ├── _966_vowel_spellchecker.rs │ ├── _967_numbers_with_same_consecutive_differences.rs │ ├── _969_pancake_sorting.rs │ ├── _970_powerful_integers.rs │ ├── _971_flip_binary_tree_to_match_preorder_traversal.rs │ ├── _972_equal_rational_numbers.rs │ ├── _973_k_closest_points_to_origin.rs │ ├── _974_subarray_sums_divisible_by_k.rs │ ├── _976_largest_perimeter_triangle.rs │ ├── _977_squares_of_a_sorted_array.rs │ ├── _978_longest_turbulent_subarray.rs │ ├── _979_distribute_coins_in_binary_tree.rs │ ├── _980_unique_paths_3.rs │ ├── _981_time_based_key_value_store.rs │ ├── _982_triples_with_bitwise_and_equal_to_zero.rs │ ├── _983_minimum_cost_for_tickets.rs │ ├── _984_string_without_aaa_or_bbb.rs │ ├── _985_sum_of_even_numbers_after_queries.rs │ ├── _986_interval_list_intersections.rs │ ├── _987_vertical_order_traversal_of_a_binary_tree.rs │ ├── _988_smallest_string_starting_from_leaf.rs │ ├── _989_add_to_array_form_of_integer.rs │ ├── _990_satisfiability_of_equality_equations.rs │ ├── _991_broken_calculator.rs │ ├── _992_subarrays_with_k_different_integers.rs │ ├── _993_cousins_in_binary_tree.rs │ ├── _994_rotting_oranges.rs │ ├── _995_minimum_number_of_k_consecutive_bit_flips.rs │ ├── _997_find_the_town_judge.rs │ ├── _998_maximum_binary_tree_2.rs │ ├── _999_available_captures_for_rook.rs │ └── mod.rs │ └── lib.rs ├── metaldnn-sys ├── Cargo.toml ├── build.rs └── src │ ├── lib.rs │ └── wrapper.h ├── metaldnn ├── Cargo.toml ├── build.rs └── src │ ├── dnn.rs │ ├── ios.m │ ├── layer.rs │ ├── lib.rs │ ├── macos.m │ ├── metaldnn.m │ ├── metaldnn.rs │ └── shaders.metal ├── migrations ├── .gitkeep ├── 2020-12-13-194959_create_leetcode_question │ ├── down.sql │ └── up.sql ├── 2020-12-15-091647_create_leetcode_description │ ├── down.sql │ └── up.sql ├── 2020-12-16-011639_create_leetcode_solution │ ├── down.sql │ └── up.sql ├── 2020-12-19-071746_create_adventofcode_description │ ├── down.sql │ └── up.sql ├── 2020-12-19-081420_create_adventofcode_solution │ ├── down.sql │ └── up.sql ├── 2021-03-16-194853_create_google_problem │ ├── down.sql │ └── up.sql └── 2021-12-20-232817_create-nes-rom │ ├── down.sql │ └── up.sql ├── mnist-data ├── Cargo.toml ├── build.rs └── src │ └── lib.rs ├── mnist ├── Cargo.toml ├── gfx-rs.png └── src │ ├── lib.rs │ └── main.rs ├── msg ├── Cargo.toml └── src │ └── lib.rs ├── nes ├── Cargo.toml ├── src │ ├── apu.rs │ ├── auto_save_manager.rs │ ├── base.rs │ ├── battery_manager.rs │ ├── breakpoint.rs │ ├── bus.rs │ ├── cheat_manager.rs │ ├── code_data_logger.rs │ ├── code_runner.rs │ ├── console.rs │ ├── console_features.rs │ ├── control_manager.rs │ ├── cpu.rs │ ├── debug_hud.rs │ ├── debugger.rs │ ├── device │ │ ├── mod.rs │ │ └── standard_controler.rs │ ├── disassembler.rs │ ├── dummy_cpu.rs │ ├── emulation_settings.rs │ ├── event_manager.rs │ ├── expression_data.rs │ ├── expression_evaluator.rs │ ├── frame_info.rs │ ├── history_viewer.rs │ ├── hook.rs │ ├── instruction_progress.rs │ ├── label_manager.rs │ ├── lib.rs │ ├── logger.rs │ ├── mapper │ │ ├── mod.rs │ │ └── nrom.rs │ ├── memory.rs │ ├── memory_access_counter.rs │ ├── memory_dumper.rs │ ├── nes_header.rs │ ├── notification_manager.rs │ ├── operation_info.rs │ ├── palette.rs │ ├── performance_tracker.rs │ ├── ppu.rs │ ├── prg_rom.rs │ ├── profiler.rs │ ├── renderer │ │ ├── mod.rs │ │ └── webgl_renderer.rs │ ├── rewind_manager.rs │ ├── rom.rs │ ├── rotate_filter.rs │ ├── save_state_manager.rs │ ├── scale_filter.rs │ ├── screen.rs │ ├── sound.rs │ ├── sound_mixer.rs │ ├── stack_frame_flags.rs │ ├── stack_frame_info.rs │ ├── state.rs │ ├── system_action_manager.rs │ ├── timer.rs │ ├── trace_logger.rs │ ├── video_decoder.rs │ ├── video_filter │ │ ├── default_video_filter.rs │ │ └── mod.rs │ ├── video_hud.rs │ ├── video_renderer.rs │ └── virtual_file.rs └── test │ ├── nestest.log │ └── nestest.nes ├── openvgdb ├── Cargo.toml └── src │ ├── lib.rs │ ├── main.rs │ ├── rom.rs │ └── schema.rs ├── readme ├── Cargo.toml ├── src │ ├── description.rs │ ├── google.rs │ ├── leetcode.rs │ ├── main.rs │ └── solution.rs └── templates │ └── readme.j2 ├── rustgym ├── Cargo.toml └── src │ └── lib.rs ├── schema ├── Cargo.toml ├── schema.rs └── src │ ├── adventofcode_description.rs │ ├── adventofcode_solution.rs │ ├── google_problem.rs │ ├── leetcode_description.rs │ ├── leetcode_question.rs │ ├── leetcode_solution.rs │ ├── lib.rs │ ├── nes_rom.rs │ └── schema.rs ├── scripts ├── .gitignore ├── certbot.sh ├── const.env ├── coturn.sh ├── create_stun_firewall_rule.sh ├── envoy.sh ├── ingest.sh ├── server.sh ├── sonic.sh └── startup.sh ├── server ├── Cargo.toml ├── src │ ├── agents │ │ ├── envelope.rs │ │ ├── mod.rs │ │ ├── registry.rs │ │ ├── search.rs │ │ ├── uap.rs │ │ └── websocket.rs │ ├── app_data.rs │ ├── context │ │ ├── adventofcode.rs │ │ ├── app.rs │ │ ├── find.rs │ │ ├── google.rs │ │ ├── home.rs │ │ ├── leetcode.rs │ │ ├── mod.rs │ │ ├── nes.rs │ │ └── sitemap.rs │ ├── db.rs │ ├── files.rs │ ├── main.rs │ ├── routes │ │ ├── adventofcode_detail.rs │ │ ├── adventofcode_index.rs │ │ ├── find.rs │ │ ├── google_detail.rs │ │ ├── google_index.rs │ │ ├── home.rs │ │ ├── leetcode_detail.rs │ │ ├── leetcode_index.rs │ │ ├── mod.rs │ │ ├── nes_detail.rs │ │ ├── nes_index.rs │ │ ├── robots.rs │ │ └── sitemap.rs │ └── session_data.rs └── templates │ ├── adventofcode-detail.j2 │ ├── adventofcode-index.j2 │ ├── desktop.j2 │ ├── find.j2 │ ├── google-detail.j2 │ ├── google-index.j2 │ ├── home.j2 │ ├── leetcode-detail.j2 │ ├── leetcode-index.j2 │ ├── nes-detail.j2 │ ├── nes-index.j2 │ ├── robots.j2 │ └── sitemap.j2 ├── static ├── css │ ├── 98.css │ ├── desktop.css │ ├── ms_sans_serif.woff2 │ ├── ms_sans_serif_bold.woff2 │ └── vs.css ├── gif │ ├── documents.gif │ ├── exe.gif │ ├── favourites.gif │ ├── find.gif │ ├── help.gif │ ├── logoff.gif │ ├── programs.gif │ ├── run.gif │ ├── settings.gif │ ├── shutdown.gif │ └── txt.gif ├── highlight.min.js └── ico │ ├── executable.ico │ ├── loudspeaker_rays.ico │ ├── user_world.ico │ └── windows.ico ├── util ├── Cargo.toml └── src │ ├── adventofcode.rs │ ├── data.rs │ ├── graph.rs │ ├── lib.rs │ ├── list.rs │ ├── nested_integer.rs │ ├── read.rs │ ├── test_gen.rs │ ├── tree.rs │ └── unionfind.rs └── wasm ├── .gitignore ├── Cargo.toml ├── cubetexture.png ├── helper.js ├── shaders ├── nes.frag └── nes.vert ├── src ├── client.rs ├── desktop.rs ├── lib.rs ├── logger.rs ├── media.rs ├── nes_emulator.rs ├── pc.rs ├── searchbar.rs ├── shaders.rs └── utils.rs └── webdriver.json /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.x86_64-unknown-linux-musl] 2 | linker = "x86_64-linux-musl-gcc" 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: warycat 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | **/*.rs.bk 3 | pkg/ 4 | .vscode 5 | .DS_Store 6 | .idea 7 | *.sqlite 8 | *.tar.gz 9 | stream/ 10 | data/ 11 | bundle.tar -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "uap-core"] 2 | path = uap-core 3 | url = https://github.com/ua-parser/uap-core.git 4 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | # format_code_in_doc_comments = true -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "rustgym", 4 | "util", 5 | "readme", 6 | "server", 7 | "schema", 8 | "consts", 9 | "characters", 10 | "wasm", 11 | "msg", 12 | "ingest", 13 | "leetcode", 14 | "adventofcode", 15 | "google", 16 | "hackerrank", 17 | "mnist-data", 18 | "nes", 19 | "openvgdb", 20 | ] 21 | -------------------------------------------------------------------------------- /adventofcode/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym-adventofcode" 3 | version = "0.1.0" 4 | authors = ["Larry Fantasy "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | [dependencies] 9 | serde_json = "1.0.60" 10 | rustgym-util = { path = "../util" } 11 | rayon = "1.5.0" 12 | md5 = "0.7.0" 13 | paste = "1.0.3" 14 | -------------------------------------------------------------------------------- /adventofcode/examples/adventofcode/2015/day10.txt: -------------------------------------------------------------------------------- 1 | 1321131112 2 | -------------------------------------------------------------------------------- /adventofcode/examples/adventofcode/2015/day11.txt: -------------------------------------------------------------------------------- 1 | cqjxjnds 2 | -------------------------------------------------------------------------------- /adventofcode/examples/adventofcode/2015/day4.txt: -------------------------------------------------------------------------------- 1 | yzbqklnj 2 | -------------------------------------------------------------------------------- /adventofcode/examples/adventofcode/2020/day13.txt: -------------------------------------------------------------------------------- 1 | 1001798 2 | 19,x,x,x,x,x,x,x,x,41,x,x,x,x,x,x,x,x,x,859,x,x,x,x,x,x,x,23,x,x,x,x,13,x,x,x,17,x,x,x,x,x,x,x,x,x,x,x,29,x,373,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,37 3 | -------------------------------------------------------------------------------- /adventofcode/examples/adventofcode/2020/day15.txt: -------------------------------------------------------------------------------- 1 | 1,2,16,19,18,0 2 | -------------------------------------------------------------------------------- /adventofcode/examples/adventofcode/2020/day17.txt: -------------------------------------------------------------------------------- 1 | ...#...# 2 | #######. 3 | ....###. 4 | .#..#... 5 | #.#..... 6 | .##..... 7 | #.####.. 8 | #....##. 9 | -------------------------------------------------------------------------------- /adventofcode/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![deny(clippy::all)] 2 | #![allow(dead_code)] 3 | #![allow(clippy::collapsible_if)] 4 | #![allow(clippy::collapsible_else_if)] 5 | #![allow(clippy::upper_case_acronyms)] 6 | #![allow(clippy::needless_range_loop)] 7 | #![allow(clippy::too_many_arguments)] 8 | #![allow(clippy::suspicious_operation_groupings)] 9 | #![allow(clippy::while_let_on_iterator)] 10 | 11 | pub mod year2015; 12 | pub mod year2020; 13 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day1/input.txt: -------------------------------------------------------------------------------- 1 | )())()) 2 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day1/output.txt: -------------------------------------------------------------------------------- 1 | -3 2 | 1 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day10/input.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day10/output.txt: -------------------------------------------------------------------------------- 1 | 82350 2 | 1166642 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day11/input.txt: -------------------------------------------------------------------------------- 1 | ghijklmn 2 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day11/output.txt: -------------------------------------------------------------------------------- 1 | ghjaabcc 2 | ghjbbcdd 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day12/input.txt: -------------------------------------------------------------------------------- 1 | [1,{"c":"red","b":2},3] -------------------------------------------------------------------------------- /adventofcode/src/year2015/day12/output.txt: -------------------------------------------------------------------------------- 1 | 6 2 | 4 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day2/input.txt: -------------------------------------------------------------------------------- 1 | 2x3x4 2 | 1x1x10 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day2/output.txt: -------------------------------------------------------------------------------- 1 | 101 2 | 48 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day3/input.txt: -------------------------------------------------------------------------------- 1 | ^>v< 2 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day3/output.txt: -------------------------------------------------------------------------------- 1 | 4 2 | 3 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day4/input.txt: -------------------------------------------------------------------------------- 1 | abcdef 2 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day4/output.txt: -------------------------------------------------------------------------------- 1 | 609043 2 | 6742839 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day5/input.txt: -------------------------------------------------------------------------------- 1 | ugknbfddgicrmopn 2 | aaa 3 | jchzalrnumimnmhp 4 | haegwjzuvuyypxyu 5 | dvszwmarrgswjxmb 6 | qjhvhtzxzqqjkmpb 7 | xxyxx 8 | uurcxstgmygtbstg 9 | ieodomkazucvgmuy 10 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day5/output.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day6/input.txt: -------------------------------------------------------------------------------- 1 | turn on 0,0 through 999,999 2 | toggle 0,0 through 999,0 3 | turn off 499,499 through 500,500 4 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day6/output.txt: -------------------------------------------------------------------------------- 1 | 998996 2 | 1001996 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day7/input.txt: -------------------------------------------------------------------------------- 1 | 123 -> x 2 | 456 -> y 3 | x AND y -> d 4 | x OR y -> e 5 | x LSHIFT 2 -> f 6 | y RSHIFT 2 -> g 7 | NOT x -> h 8 | NOT y -> i 9 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day7/output.txt: -------------------------------------------------------------------------------- 1 | 0 2 | 0 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day8/input.txt: -------------------------------------------------------------------------------- 1 | "" 2 | "abc" 3 | "aaa\"aaa" 4 | "\x27" 5 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day8/output.txt: -------------------------------------------------------------------------------- 1 | 12 2 | 19 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day9/input.txt: -------------------------------------------------------------------------------- 1 | London to Dublin = 464 2 | London to Belfast = 518 3 | Dublin to Belfast = 141 4 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/day9/output.txt: -------------------------------------------------------------------------------- 1 | 605 2 | 982 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2015/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod day1; 2 | pub mod day2; 3 | pub mod day3; 4 | pub mod day4; 5 | pub mod day5; 6 | pub mod day6; 7 | pub mod day7; 8 | pub mod day8; 9 | pub mod day9; 10 | 11 | pub mod day10; 12 | pub mod day11; 13 | pub mod day12; 14 | 15 | // use rustgym_util::*; 16 | // use std::fmt::Write; 17 | // use std::io::*; 18 | 19 | // pub fn solve(reader: &mut dyn BufRead, writer: &mut dyn Write) { 20 | // let mut it = reader.lines().map(|l| l.unwrap()); 21 | // writeln!(writer, "{}", res1).unwrap(); 22 | // writeln!(writer, "{}", res2).unwrap(); 23 | // } 24 | 25 | // advent_of_code!(test, "input.txt", "output.txt"); 26 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day1/input.txt: -------------------------------------------------------------------------------- 1 | 1721 2 | 979 3 | 366 4 | 299 5 | 675 6 | 1456 7 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day1/output.txt: -------------------------------------------------------------------------------- 1 | 514579 2 | 241861950 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day10/input.txt: -------------------------------------------------------------------------------- 1 | 28 2 | 33 3 | 18 4 | 42 5 | 31 6 | 14 7 | 46 8 | 20 9 | 48 10 | 47 11 | 24 12 | 23 13 | 49 14 | 45 15 | 19 16 | 38 17 | 39 18 | 11 19 | 1 20 | 32 21 | 25 22 | 35 23 | 8 24 | 17 25 | 7 26 | 9 27 | 4 28 | 2 29 | 34 30 | 10 31 | 3 32 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day10/output.txt: -------------------------------------------------------------------------------- 1 | 220 2 | 19208 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day11/input.txt: -------------------------------------------------------------------------------- 1 | L.LL.LL.LL 2 | LLLLLLL.LL 3 | L.L.L..L.. 4 | LLLL.LL.LL 5 | L.LL.LL.LL 6 | L.LLLLL.LL 7 | ..L.L..... 8 | LLLLLLLLLL 9 | L.LLLLLL.L 10 | L.LLLLL.LL 11 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day11/output.txt: -------------------------------------------------------------------------------- 1 | 37 2 | 26 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day12/input.txt: -------------------------------------------------------------------------------- 1 | F10 2 | N3 3 | F7 4 | R90 5 | F11 6 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day12/output.txt: -------------------------------------------------------------------------------- 1 | 25 2 | 286 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day13/input.txt: -------------------------------------------------------------------------------- 1 | 939 2 | 7,13,x,x,59,x,31,19 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day13/output.txt: -------------------------------------------------------------------------------- 1 | 295 2 | 1068781 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day14/input.txt: -------------------------------------------------------------------------------- 1 | mask = 000000000000000000000000000000X1001X 2 | mem[42] = 100 3 | mask = 00000000000000000000000000000000X0XX 4 | mem[26] = 1 5 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day14/output.txt: -------------------------------------------------------------------------------- 1 | 51 2 | 208 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day15/input.txt: -------------------------------------------------------------------------------- 1 | 3,1,2 2 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day15/output.txt: -------------------------------------------------------------------------------- 1 | 1836 2 | 362 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day16/input.txt: -------------------------------------------------------------------------------- 1 | class: 1-3 or 5-7 2 | row: 6-11 or 33-44 3 | seat: 13-40 or 45-50 4 | 5 | your ticket: 6 | 7,1,14 7 | 8 | nearby tickets: 9 | 7,3,47 10 | 40,4,50 11 | 55,2,20 12 | 38,6,12 13 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day16/output.txt: -------------------------------------------------------------------------------- 1 | 71 2 | 1 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day17/input.txt: -------------------------------------------------------------------------------- 1 | .#. 2 | ..# 3 | ### 4 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day17/output.txt: -------------------------------------------------------------------------------- 1 | 112 2 | 848 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day18/input.txt: -------------------------------------------------------------------------------- 1 | 2 * 3 + (4 * 5) 2 | 5 + (8 * 3 + 9 + 3 * 4 * 3) 3 | 5 * 9 * (7 * 3 * 3 + 9 * 3 + (8 + 6 * 4)) 4 | ((2 + 4 * 9) * (6 + 9 * 8 + 6) + 6) + 2 + 4 * 2 5 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day18/output.txt: -------------------------------------------------------------------------------- 1 | 26335 2 | 693891 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day19/output.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 12 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day2/input.txt: -------------------------------------------------------------------------------- 1 | 1-3 a: abcde 2 | 1-3 b: cdefg 3 | 2-9 c: ccccccccc 4 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day2/output.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 1 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day3/input.txt: -------------------------------------------------------------------------------- 1 | ..##....... 2 | #...#...#.. 3 | .#....#..#. 4 | ..#.#...#.# 5 | .#...##..#. 6 | ..#.##..... 7 | .#.#.#....# 8 | .#........# 9 | #.##...#... 10 | #...##....# 11 | .#..#...#.# 12 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day3/output.txt: -------------------------------------------------------------------------------- 1 | 7 2 | 336 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day4/input.txt: -------------------------------------------------------------------------------- 1 | ecl:gry pid:860033327 eyr:2020 hcl:#fffffd 2 | byr:1937 iyr:2017 cid:147 hgt:183cm 3 | 4 | iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884 5 | hcl:#cfa07d byr:1929 6 | 7 | hcl:#ae17e1 iyr:2013 8 | eyr:2024 9 | ecl:brn pid:760753108 byr:1931 10 | hgt:179cm 11 | 12 | hcl:#cfa07d eyr:2025 pid:166559648 13 | iyr:2011 ecl:brn hgt:59in 14 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day4/output.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day5/output.txt: -------------------------------------------------------------------------------- 1 | 922 2 | 747 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day6/input.txt: -------------------------------------------------------------------------------- 1 | abc 2 | 3 | a 4 | b 5 | c 6 | 7 | ab 8 | ac 9 | 10 | a 11 | a 12 | a 13 | a 14 | 15 | b 16 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day6/output.txt: -------------------------------------------------------------------------------- 1 | 11 2 | 6 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day7/input.txt: -------------------------------------------------------------------------------- 1 | light red bags contain 1 bright white bag, 2 muted yellow bags. 2 | dark orange bags contain 3 bright white bags, 4 muted yellow bags. 3 | bright white bags contain 1 shiny gold bag. 4 | muted yellow bags contain 2 shiny gold bags, 9 faded blue bags. 5 | shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags. 6 | dark olive bags contain 3 faded blue bags, 4 dotted black bags. 7 | vibrant plum bags contain 5 faded blue bags, 6 dotted black bags. 8 | faded blue bags contain no other bags. 9 | dotted black bags contain no other bags. 10 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day7/output.txt: -------------------------------------------------------------------------------- 1 | 4 2 | 32 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day8/input.txt: -------------------------------------------------------------------------------- 1 | nop +0 2 | acc +1 3 | jmp +4 4 | acc +3 5 | jmp -3 6 | acc -99 7 | acc +1 8 | jmp -4 9 | acc +6 10 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day8/output.txt: -------------------------------------------------------------------------------- 1 | 5 2 | 8 3 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day9/input.txt: -------------------------------------------------------------------------------- 1 | 35 2 | 20 3 | 15 4 | 25 5 | 47 6 | 40 7 | 62 8 | 55 9 | 65 10 | 95 11 | 102 12 | 117 13 | 150 14 | 182 15 | 127 16 | 219 17 | 299 18 | 277 19 | 309 20 | 576 21 | -------------------------------------------------------------------------------- /adventofcode/src/year2020/day9/output.txt: -------------------------------------------------------------------------------- 1 | 127 2 | 62 3 | -------------------------------------------------------------------------------- /bundle.txt: -------------------------------------------------------------------------------- 1 | target/x86_64-unknown-linux-musl/release/openvgdb 2 | target/x86_64-unknown-linux-musl/release/rustgym-server 3 | target/x86_64-unknown-linux-musl/release/rustgym-readme 4 | target/x86_64-unknown-linux-musl/release/rustgym-ingest 5 | config/ 6 | scripts/ 7 | pkg/ 8 | data/ 9 | static/ -------------------------------------------------------------------------------- /characters/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym-characters" 3 | version = "0.1.0" 4 | authors = ["Larry Fantasy "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /characters/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub const CHARACTERS: &[&str] = &[ 2 | "Banjo", 3 | "Bowser", 4 | "Ciri", 5 | "Diddy Kong", 6 | "Donkey Kong", 7 | "Geralt of Rivia", 8 | "Kratos", 9 | "Lara Croft", 10 | "Link", 11 | "Mario", 12 | "Megaman", 13 | "Pacman", 14 | "Pikachu", 15 | "Princess Zelda", 16 | "Princess Peach", 17 | "Rayman", 18 | "Sonic", 19 | "Spyro", 20 | "Yennefer", 21 | "Yoshi", 22 | ]; 23 | 24 | #[cfg(test)] 25 | mod tests { 26 | use super::CHARACTERS; 27 | #[test] 28 | fn characters() { 29 | assert_eq!(CHARACTERS.len(), 20); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /clippy.toml: -------------------------------------------------------------------------------- 1 | single-char-binding-names-threshold = 10 -------------------------------------------------------------------------------- /consts/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym-consts" 3 | version = "0.1.0" 4 | authors = ["Yinchu Xia "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | [dependencies] 9 | log = "0.4.14" 10 | -------------------------------------------------------------------------------- /diesel.toml: -------------------------------------------------------------------------------- 1 | # For documentation on how to configure this file, 2 | # see diesel.rs/guides/configuring-diesel-cli 3 | [print_schema] 4 | file = "schema/src/schema.rs" 5 | -------------------------------------------------------------------------------- /google/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym-google" 3 | version = "0.1.0" 4 | authors = ["Larry Fantasy "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | [dependencies] 9 | rustgym-util = { path = "../util" } 10 | -------------------------------------------------------------------------------- /google/src/codejam/mod.rs: -------------------------------------------------------------------------------- 1 | mod year2008; 2 | -------------------------------------------------------------------------------- /google/src/codejam/year2008/mod.rs: -------------------------------------------------------------------------------- 1 | mod round01; 2 | -------------------------------------------------------------------------------- /google/src/codejam/year2008/round01/_1_fly_swatter/input.txt: -------------------------------------------------------------------------------- 1 | 5 2 | 0.250000 1.000000 0.100000 0.010000 0.500000 3 | 0.250000 1.000000 0.100000 0.010000 0.900000 4 | 0.000010 10000.000000 0.000010 0.000010 1000.000000 5 | 0.400000 10000.000000 0.000010 0.000010 700.000000 6 | 1.000000 100.000000 1.000000 1.000000 10.000000 7 | -------------------------------------------------------------------------------- /google/src/codejam/year2008/round01/_1_fly_swatter/output.txt: -------------------------------------------------------------------------------- 1 | Case #1: 1.000000 2 | Case #2: 0.910015 3 | Case #3: 0.000000 4 | Case #4: 0.002371 5 | Case #5: 0.573972 6 | -------------------------------------------------------------------------------- /google/src/codejam/year2008/round01/mod.rs: -------------------------------------------------------------------------------- 1 | mod _1_fly_swatter; 2 | -------------------------------------------------------------------------------- /google/src/kickstart/mod.rs: -------------------------------------------------------------------------------- 1 | mod year2013; 2 | mod year2020; 3 | mod year2021; 4 | -------------------------------------------------------------------------------- /google/src/kickstart/year2013/mod.rs: -------------------------------------------------------------------------------- 1 | mod round01; 2 | -------------------------------------------------------------------------------- /google/src/kickstart/year2013/round01/_1_moist/input.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 | Oksana Baiul 4 | Michelle Kwan 5 | 3 6 | Elvis Stojko 7 | Evgeni Plushenko 8 | Kristi Yamaguchi 9 | -------------------------------------------------------------------------------- /google/src/kickstart/year2013/round01/_1_moist/mod.rs: -------------------------------------------------------------------------------- 1 | use rustgym_util::*; 2 | use std::fmt::Write; 3 | use std::io::*; 4 | 5 | fn solve(case_no: usize, reader: &mut impl BufRead, writer: &mut impl Write) { 6 | let n = reader.parse_line(); 7 | let mut max_line = "".to_string(); 8 | let mut res = 0; 9 | for _ in 0..n { 10 | let line = reader.collect_string(); 11 | if line > max_line { 12 | max_line = line; 13 | } else { 14 | res += 1; 15 | } 16 | } 17 | writeln!(writer, "Case #{}: {}", case_no, res).unwrap(); 18 | } 19 | 20 | google_test_gen!(test, "input.txt", "output.txt"); 21 | -------------------------------------------------------------------------------- /google/src/kickstart/year2013/round01/_1_moist/output.txt: -------------------------------------------------------------------------------- 1 | Case #1: 1 2 | Case #2: 0 3 | -------------------------------------------------------------------------------- /google/src/kickstart/year2013/round01/_2_captain_hammer/input.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 98 980 3 | 98 490 4 | 299 1234 5 | -------------------------------------------------------------------------------- /google/src/kickstart/year2013/round01/_2_captain_hammer/output.txt: -------------------------------------------------------------------------------- 1 | Case #1: 44.9999993 2 | Case #2: 15.0000000 3 | Case #3: 3.8870928 4 | -------------------------------------------------------------------------------- /google/src/kickstart/year2013/round01/_3_bad_horse/input.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 1 3 | Dead_Bowie Fake_Thomas_Jefferson 4 | 3 5 | Dead_Bowie Fake_Thomas_Jefferson 6 | Fake_Thomas_Jefferson Fury_Leika 7 | Fury_Leika Dead_Bowie 8 | -------------------------------------------------------------------------------- /google/src/kickstart/year2013/round01/_3_bad_horse/output.txt: -------------------------------------------------------------------------------- 1 | Case #1: Yes 2 | Case #2: No 3 | -------------------------------------------------------------------------------- /google/src/kickstart/year2013/round01/mod.rs: -------------------------------------------------------------------------------- 1 | mod _1_moist; 2 | mod _2_captain_hammer; 3 | mod _3_bad_horse; 4 | -------------------------------------------------------------------------------- /google/src/kickstart/year2020/mod.rs: -------------------------------------------------------------------------------- 1 | mod round01; 2 | -------------------------------------------------------------------------------- /google/src/kickstart/year2020/round01/_1_allocation/input.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 4 100 3 | 20 90 40 90 4 | 4 50 5 | 30 30 10 10 6 | 3 300 7 | 999 999 999 8 | -------------------------------------------------------------------------------- /google/src/kickstart/year2020/round01/_1_allocation/output.txt: -------------------------------------------------------------------------------- 1 | Case #1: 2 2 | Case #2: 3 3 | Case #3: 0 4 | -------------------------------------------------------------------------------- /google/src/kickstart/year2020/round01/mod.rs: -------------------------------------------------------------------------------- 1 | mod _1_allocation; 2 | -------------------------------------------------------------------------------- /google/src/kickstart/year2021/mod.rs: -------------------------------------------------------------------------------- 1 | mod round01; 2 | -------------------------------------------------------------------------------- /google/src/kickstart/year2021/round01/_1_k_goodness_string/input.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 5 1 3 | ABCAA 4 | 4 2 5 | ABAA 6 | -------------------------------------------------------------------------------- /google/src/kickstart/year2021/round01/_1_k_goodness_string/output.txt: -------------------------------------------------------------------------------- 1 | Case #1: 0 2 | Case #2: 1 3 | -------------------------------------------------------------------------------- /google/src/kickstart/year2021/round01/_2_l_shaped_plots/input.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 4 3 3 | 1 0 0 4 | 1 0 1 5 | 1 0 0 6 | 1 1 0 7 | 6 4 8 | 1 0 0 0 9 | 1 0 0 1 10 | 1 1 1 1 11 | 1 0 1 0 12 | 1 0 1 0 13 | 1 1 1 0 14 | -------------------------------------------------------------------------------- /google/src/kickstart/year2021/round01/_2_l_shaped_plots/output.txt: -------------------------------------------------------------------------------- 1 | Case #1: 1 2 | Case #2: 9 3 | -------------------------------------------------------------------------------- /google/src/kickstart/year2021/round01/_3_rabbit_house/input.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 1 3 3 | 3 4 3 4 | 1 3 5 | 3 0 0 6 | 3 3 7 | 0 0 0 8 | 0 2 0 9 | 0 0 0 10 | -------------------------------------------------------------------------------- /google/src/kickstart/year2021/round01/_3_rabbit_house/output.txt: -------------------------------------------------------------------------------- 1 | Case #1: 0 2 | Case #2: 3 3 | Case #3: 4 4 | -------------------------------------------------------------------------------- /google/src/kickstart/year2021/round01/_4_checksum/input.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 3 3 | 1 -1 0 4 | 0 1 0 5 | 1 1 1 6 | 0 1 0 7 | 0 0 0 8 | 0 0 0 9 | 1 1 1 10 | 0 0 1 11 | 2 12 | -1 -1 13 | -1 -1 14 | 1 10 15 | 100 1000 16 | 1 0 17 | 0 1 18 | 3 19 | -1 -1 -1 20 | -1 -1 -1 21 | 0 0 0 22 | 1 1 3 23 | 5 1 4 24 | 0 0 0 25 | 0 0 0 26 | 0 0 0 27 | -------------------------------------------------------------------------------- /google/src/kickstart/year2021/round01/_4_checksum/output.txt: -------------------------------------------------------------------------------- 1 | Case #1: 0 2 | Case #2: 1 3 | Case #3: 2 4 | -------------------------------------------------------------------------------- /google/src/kickstart/year2021/round01/mod.rs: -------------------------------------------------------------------------------- 1 | mod _1_k_goodness_string; 2 | mod _2_l_shaped_plots; 3 | mod _3_rabbit_house; 4 | -------------------------------------------------------------------------------- /gvc-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gvc-sys" 3 | version = "0.1.1" 4 | authors = ["Yinchu Xia "] 5 | edition = "2018" 6 | license = "MIT OR Apache-2.0" 7 | description = "graphviz rust bindings" 8 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 9 | 10 | [dependencies] 11 | lazy_static = "1.4.0" 12 | 13 | [build-dependencies] 14 | cc = "1.0.52" 15 | glob = "0.3.0" 16 | pkg-config = "0.3.17" 17 | bindgen = "0.53.2" 18 | regex = "1.3.7" 19 | 20 | -------------------------------------------------------------------------------- /gvc-sys/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_camel_case_types)] 2 | #![allow(non_snake_case)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(clippy::all)] 5 | 6 | #[allow(dead_code)] 7 | pub mod bindings; 8 | 9 | pub use bindings::*; 10 | -------------------------------------------------------------------------------- /gvc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym-gvc" 3 | version = "0.1.0" 4 | authors = ["Yinchu Xia "] 5 | edition = "2018" 6 | license = "MIT OR Apache-2.0" 7 | description = "generate svg for some data structure in rustgym" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | gvc-sys = {path='../gvc-sys', version = '0.1.0'} 13 | rustgym-util = {path='../util', version = '0.1.0'} 14 | -------------------------------------------------------------------------------- /hackerrank/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym-hackerrank" 3 | version = "0.1.0" 4 | authors = ["Larry Fantasy "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | [dependencies] 9 | rustgym-util = { path = "../util" } 10 | -------------------------------------------------------------------------------- /hackerrank/src/hello_world/input00.txt: -------------------------------------------------------------------------------- 1 | Welcome to 30 Days of Code! -------------------------------------------------------------------------------- /hackerrank/src/hello_world/input01.txt: -------------------------------------------------------------------------------- 1 | HackerRank is the best! -------------------------------------------------------------------------------- /hackerrank/src/hello_world/mod.rs: -------------------------------------------------------------------------------- 1 | use rustgym_util::*; 2 | use std::fmt::Write; 3 | use std::io::*; 4 | 5 | fn solve(reader: &mut impl RustGymRead, writer: &mut impl Write) { 6 | writeln!(writer, "Hello, World.").unwrap(); 7 | let line = reader.collect_string(); 8 | write!(writer, "{}", line).unwrap(); 9 | } 10 | 11 | test_gen!(test00, "input00.txt", "output00.txt"); 12 | test_gen!(test01, "input01.txt", "output01.txt"); 13 | -------------------------------------------------------------------------------- /hackerrank/src/hello_world/output00.txt: -------------------------------------------------------------------------------- 1 | Hello, World. 2 | Welcome to 30 Days of Code! -------------------------------------------------------------------------------- /hackerrank/src/hello_world/output01.txt: -------------------------------------------------------------------------------- 1 | Hello, World. 2 | HackerRank is the best! -------------------------------------------------------------------------------- /hackerrank/src/hello_world/problem.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/hackerrank/src/hello_world/problem.pdf -------------------------------------------------------------------------------- /hackerrank/src/jumping_on_the_clouds/input00.txt: -------------------------------------------------------------------------------- 1 | 7 2 | 0 0 1 0 0 1 0 -------------------------------------------------------------------------------- /hackerrank/src/jumping_on_the_clouds/input01.txt: -------------------------------------------------------------------------------- 1 | 6 2 | 0 0 0 1 0 0 -------------------------------------------------------------------------------- /hackerrank/src/jumping_on_the_clouds/output00.txt: -------------------------------------------------------------------------------- 1 | 4 -------------------------------------------------------------------------------- /hackerrank/src/jumping_on_the_clouds/output01.txt: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /hackerrank/src/jumping_on_the_clouds/problem.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/hackerrank/src/jumping_on_the_clouds/problem.pdf -------------------------------------------------------------------------------- /hackerrank/src/repeated_string/input00.txt: -------------------------------------------------------------------------------- 1 | aba 2 | 10 3 | -------------------------------------------------------------------------------- /hackerrank/src/repeated_string/input01.txt: -------------------------------------------------------------------------------- 1 | a 2 | 1000000000000 3 | -------------------------------------------------------------------------------- /hackerrank/src/repeated_string/output00.txt: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /hackerrank/src/repeated_string/output01.txt: -------------------------------------------------------------------------------- 1 | 1000000000000 2 | -------------------------------------------------------------------------------- /hackerrank/src/repeated_string/problem.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/hackerrank/src/repeated_string/problem.pdf -------------------------------------------------------------------------------- /hackerrank/src/sock_merchant/input00.txt: -------------------------------------------------------------------------------- 1 | 9 2 | 10 20 20 10 10 30 50 10 20 -------------------------------------------------------------------------------- /hackerrank/src/sock_merchant/input08.txt: -------------------------------------------------------------------------------- 1 | 10 2 | 1 1 3 1 2 1 3 3 3 3 -------------------------------------------------------------------------------- /hackerrank/src/sock_merchant/output00.txt: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /hackerrank/src/sock_merchant/output08.txt: -------------------------------------------------------------------------------- 1 | 4 -------------------------------------------------------------------------------- /hackerrank/src/sock_merchant/problem.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/hackerrank/src/sock_merchant/problem.pdf -------------------------------------------------------------------------------- /ingest/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym-ingest" 3 | version = "0.1.0" 4 | authors = ["Larry Fantasy "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | [dependencies] 9 | sonic-channel = { version = "0.4.0", features = ["ingest", "control"] } 10 | anyhow = "1.0.38" 11 | diesel = { version = "1.4.8", features = [ 12 | "sqlite", 13 | "r2d2", 14 | "chrono", 15 | "uuidv07" 16 | ] } 17 | rustgym-schema = { path = "../schema" } 18 | rustgym-consts = { path = "../consts" } 19 | html2text = "0.2.1" 20 | -------------------------------------------------------------------------------- /leetcode/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym-leetcode" 3 | version = "0.1.0" 4 | authors = ["Larry Fantasy "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | [dependencies] 9 | rustgym-util = { path = "../util" } 10 | rand = "0.7.3" 11 | assert_approx_eq = "1.1.0" 12 | paste = "1.0.3" 13 | pretty_assertions = "0.7.2" 14 | threadpool = "1.8.1" 15 | -------------------------------------------------------------------------------- /leetcode/desc/d0/22.md: -------------------------------------------------------------------------------- 1 |

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

2 | 3 |

 

4 |

Example 1:

5 |
Input: n = 3
 6 | Output: ["((()))","(()())","(())()","()(())","()()()"]
 7 | 

Example 2:

8 |
Input: n = 1
 9 | Output: ["()"]
10 | 
11 |

 

12 |

Constraints:

13 | 14 |
    15 |
  • 1 <= n <= 8
  • 16 |
17 |
18 | -------------------------------------------------------------------------------- /leetcode/desc/d0/92.md: -------------------------------------------------------------------------------- 1 |

Reverse a linked list from position m to n. Do it in one-pass.

2 | 3 |

Note: 1 ≤ mn ≤ length of list.

4 | 5 |

Example:

6 | 7 |
Input: 1->2->3->4->5->NULL, m = 2, n = 4
 8 | Output: 1->4->3->2->5->NULL
 9 | 
10 |
11 | -------------------------------------------------------------------------------- /leetcode/desc/d1/101.md: -------------------------------------------------------------------------------- 1 |

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).

2 | 3 |

For example, this binary tree [1,2,2,3,4,4,3] is symmetric:

4 | 5 |
    1
 6 |    / \
 7 |   2   2
 8 |  / \ / \
 9 | 3  4 4  3
10 | 
11 | 12 |

 

13 | 14 |

But the following [1,2,2,null,3,null,3] is not:

15 | 16 |
    1
17 |    / \
18 |   2   2
19 |    \   \
20 |    3    3
21 | 
22 | 23 |

 

24 | 25 |

Follow up: Solve it both recursively and iteratively.

26 |
-------------------------------------------------------------------------------- /leetcode/desc/d1/102.md: -------------------------------------------------------------------------------- 1 |

Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).

2 | 3 |

4 | For example:
5 | Given binary tree [3,9,20,null,null,15,7],
6 |

    3
 7 |    / \
 8 |   9  20
 9 |     /  \
10 |    15   7
11 | 
12 |

13 |

14 | return its level order traversal as:
15 |

[
16 |   [3],
17 |   [9,20],
18 |   [15,7]
19 | ]
20 | 
21 |

-------------------------------------------------------------------------------- /leetcode/desc/d1/103.md: -------------------------------------------------------------------------------- 1 |

Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).

2 | 3 |

4 | For example:
5 | Given binary tree [3,9,20,null,null,15,7],
6 |

    3
 7 |    / \
 8 |   9  20
 9 |     /  \
10 |    15   7
11 | 
12 |

13 |

14 | return its zigzag level order traversal as:
15 |

[
16 |   [3],
17 |   [20,9],
18 |   [15,7]
19 | ]
20 | 
21 |

-------------------------------------------------------------------------------- /leetcode/desc/d1/105.md: -------------------------------------------------------------------------------- 1 |

Given preorder and inorder traversal of a tree, construct the binary tree.

2 | 3 |

Note:
4 | You may assume that duplicates do not exist in the tree.

5 | 6 |

For example, given

7 | 8 |
preorder = [3,9,20,15,7]
 9 | inorder = [9,3,15,20,7]
10 | 11 |

Return the following binary tree:

12 | 13 |
    3
14 |    / \
15 |   9  20
16 |     /  \
17 |    15   7
18 |
-------------------------------------------------------------------------------- /leetcode/desc/d1/106.md: -------------------------------------------------------------------------------- 1 |

Given inorder and postorder traversal of a tree, construct the binary tree.

2 | 3 |

Note:
4 | You may assume that duplicates do not exist in the tree.

5 | 6 |

For example, given

7 | 8 |
inorder = [9,3,15,20,7]
 9 | postorder = [9,15,7,20,3]
10 | 11 |

Return the following binary tree:

12 | 13 |
    3
14 |    / \
15 |   9  20
16 |     /  \
17 |    15   7
18 | 
19 |
-------------------------------------------------------------------------------- /leetcode/desc/d1/107.md: -------------------------------------------------------------------------------- 1 |

Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).

2 | 3 |

4 | For example:
5 | Given binary tree [3,9,20,null,null,15,7],
6 |

    3
 7 |    / \
 8 |   9  20
 9 |     /  \
10 |    15   7
11 | 
12 |

13 |

14 | return its bottom-up level order traversal as:
15 |

[
16 |   [15,7],
17 |   [9,20],
18 |   [3]
19 | ]
20 | 
21 |

-------------------------------------------------------------------------------- /leetcode/desc/d1/108.md: -------------------------------------------------------------------------------- 1 |

Given an array where elements are sorted in ascending order, convert it to a height balanced BST.

2 | 3 |

For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.

4 | 5 |

Example:

6 | 7 |
Given the sorted array: [-10,-3,0,5,9],
 8 | 
 9 | One possible answer is: [0,-3,9,-10,null,5], which represents the following height balanced BST:
10 | 
11 |       0
12 |      / \
13 |    -3   9
14 |    /   /
15 |  -10  5
16 | 
17 |
-------------------------------------------------------------------------------- /leetcode/desc/d1/118.md: -------------------------------------------------------------------------------- 1 |

Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.

2 | 3 |


4 | In Pascal's triangle, each number is the sum of the two numbers directly above it.

5 | 6 |

Example:

7 | 8 |
Input: 5
 9 | Output:
10 | [
11 |      [1],
12 |     [1,1],
13 |    [1,2,1],
14 |   [1,3,3,1],
15 |  [1,4,6,4,1]
16 | ]
17 | 
18 |
-------------------------------------------------------------------------------- /leetcode/desc/d1/152.md: -------------------------------------------------------------------------------- 1 |

Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.

2 | 3 |

Example 1:

4 | 5 |
Input: [2,3,-2,4]
 6 | Output: 6
 7 | Explanation: [2,3] has the largest product 6.
 8 | 
9 | 10 |

Example 2:

11 | 12 |
Input: [-2,0,-1]
13 | Output: 0
14 | Explanation: The result cannot be 2, because [-2,-1] is not a subarray.
15 |
-------------------------------------------------------------------------------- /leetcode/desc/d1/159.md: -------------------------------------------------------------------------------- 1 |

Given a string s , find the length of the longest substring t  that contains at most 2 distinct characters.

2 | 3 |

Example 1:

4 | 5 |
Input: "eceba"
 6 | Output: 3
 7 | Explanation: t is "ece" which its length is 3.
 8 | 
9 | 10 |

Example 2:

11 | 12 |
Input: "ccaabbb"
13 | Output: 5
14 | Explanation: t is "aabbb" which its length is 5.
15 | 
16 |
-------------------------------------------------------------------------------- /leetcode/desc/d1/199.md: -------------------------------------------------------------------------------- 1 |

Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

2 | 3 |

Example:

4 | 5 |
Input: [1,2,3,null,5,null,4]
 6 | Output: [1, 3, 4]
 7 | Explanation:
 8 | 
 9 |    1            <---
10 |  /   \
11 | 2     3         <---
12 |  \     \
13 |   5     4       <---
14 | 
-------------------------------------------------------------------------------- /leetcode/desc/d12/1287.md: -------------------------------------------------------------------------------- 1 |

Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time.

2 | 3 |

Return that integer.

4 | 5 |

 

6 |

Example 1:

7 |
Input: arr = [1,2,2,6,6,6,6,7,10]
 8 | Output: 6
 9 | 
10 |

 

11 |

Constraints:

12 | 13 |
    14 |
  • 1 <= arr.length <= 10^4
  • 15 |
  • 0 <= arr[i] <= 10^5
  • 16 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/201.md: -------------------------------------------------------------------------------- 1 |

Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.

2 | 3 |

Example 1:

4 | 5 |
Input: [5,7]
 6 | Output: 4
 7 | 
8 | 9 |

Example 2:

10 | 11 |
Input: [0,1]
12 | Output: 0
-------------------------------------------------------------------------------- /leetcode/desc/d2/203.md: -------------------------------------------------------------------------------- 1 |

Remove all elements from a linked list of integers that have value val.

2 | 3 |

Example:

4 | 5 |
Input:  1->2->6->3->4->5->6, val = 6
6 | Output: 1->2->3->4->5
7 | 
8 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/206.md: -------------------------------------------------------------------------------- 1 |

Reverse a singly linked list.

2 | 3 |

Example:

4 | 5 |
Input: 1->2->3->4->5->NULL
 6 | Output: 5->4->3->2->1->NULL
 7 | 
8 | 9 |

Follow up:

10 | 11 |

A linked list can be reversed either iteratively or recursively. Could you implement both?

12 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/208.md: -------------------------------------------------------------------------------- 1 |

Implement a trie with insert, search, and startsWith methods.

2 | 3 |

Example:

4 | 5 |
Trie trie = new Trie();
 6 | 
 7 | trie.insert("apple");
 8 | trie.search("apple");   // returns true
 9 | trie.search("app");     // returns false
10 | trie.startsWith("app"); // returns true
11 | trie.insert("app");   
12 | trie.search("app");     // returns true
13 | 
14 | 15 |

Note:

16 | 17 |
    18 |
  • You may assume that all inputs are consist of lowercase letters a-z.
  • 19 |
  • All inputs are guaranteed to be non-empty strings.
  • 20 |
21 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/215.md: -------------------------------------------------------------------------------- 1 |

Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.

2 | 3 |

Example 1:

4 | 5 |
Input: [3,2,1,5,6,4] and k = 2
 6 | Output: 5
 7 | 
8 | 9 |

Example 2:

10 | 11 |
Input: [3,2,3,1,2,4,5,5,6] and k = 4
12 | Output: 4
13 | 14 |

Note:
15 | You may assume k is always valid, 1 ≤ k ≤ array's length.

16 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/217.md: -------------------------------------------------------------------------------- 1 |

Given an array of integers, find if the array contains any duplicates.

2 | 3 |

Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.

4 | 5 |

Example 1:

6 | 7 |
Input: [1,2,3,1]
 8 | Output: true
9 | 10 |

Example 2:

11 | 12 |
Input: [1,2,3,4]
13 | Output: false
14 | 15 |

Example 3:

16 | 17 |
Input: [1,1,1,3,3,4,3,2,4,2]
18 | Output: true
19 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/233.md: -------------------------------------------------------------------------------- 1 |

Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.

2 | 3 |

 

4 |

Example 1:

5 | 6 |
Input: n = 13
 7 | Output: 6
 8 | 
9 | 10 |

Example 2:

11 | 12 |
Input: n = 0
13 | Output: 0
14 | 
15 | 16 |

 

17 |

Constraints:

18 | 19 |
    20 |
  • 0 <= n <= 2 * 109
  • 21 |
22 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/234.md: -------------------------------------------------------------------------------- 1 |

Given a singly linked list, determine if it is a palindrome.

2 | 3 |

Example 1:

4 | 5 |
Input: 1->2
 6 | Output: false
7 | 8 |

Example 2:

9 | 10 |
Input: 1->2->2->1
11 | Output: true
12 | 13 |

Follow up:
14 | Could you do it in O(n) time and O(1) space?

15 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/247.md: -------------------------------------------------------------------------------- 1 |

A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

2 | 3 |

Find all strobogrammatic numbers that are of length = n.

4 | 5 |

Example:

6 | 7 |
Input:  n = 2
 8 | Output: ["11","69","88","96"]
 9 | 
10 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/248.md: -------------------------------------------------------------------------------- 1 |

A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

2 | 3 |

Write a function to count the total strobogrammatic numbers that exist in the range of low <= num <= high.

4 | 5 |

Example:

6 | 7 |
Input: low = "50", high = "100"
 8 | Output: 3 
 9 | Explanation: 69, 88, and 96 are three strobogrammatic numbers.
10 | 11 |

Note:
12 | Because the range might be a large number, the low and high numbers are represented as string.

13 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/249.md: -------------------------------------------------------------------------------- 1 |

Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:

2 | 3 |
"abc" -> "bcd" -> ... -> "xyz"
4 | 5 |

Given a list of non-empty strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence.

6 | 7 |

Example:

8 | 9 |
Input: ["abc", "bcd", "acef", "xyz", "az", "ba", "a", "z"],
10 | Output: 
11 | [
12 |   ["abc","bcd","xyz"],
13 |   ["az","ba"],
14 |   ["acef"],
15 |   ["a","z"]
16 | ]
17 | 
18 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/257.md: -------------------------------------------------------------------------------- 1 |

Given a binary tree, return all root-to-leaf paths.

2 | 3 |

Note: A leaf is a node with no children.

4 | 5 |

Example:

6 | 7 |
Input:
 8 | 
 9 |    1
10 |  /   \
11 | 2     3
12 |  \
13 |   5
14 | 
15 | Output: ["1->2->5", "1->3"]
16 | 
17 | Explanation: All root-to-leaf paths are: 1->2->5, 1->3
18 | 
-------------------------------------------------------------------------------- /leetcode/desc/d2/258.md: -------------------------------------------------------------------------------- 1 |

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.

2 | 3 |

Example:

4 | 5 |
Input: 38
 6 | Output: 2 
 7 | Explanation: The process is like: 3 + 8 = 11, 1 + 1 = 2. 
 8 |              Since 2 has only one digit, return it.
 9 | 
10 | 11 |

Follow up:
12 | Could you do it without any loop/recursion in O(1) runtime?

-------------------------------------------------------------------------------- /leetcode/desc/d2/264.md: -------------------------------------------------------------------------------- 1 |

Write a program to find the n-th ugly number.

2 | 3 |

Ugly numbers are positive numbers whose prime factors only include 2, 3, 5

4 | 5 |

Example:

6 | 7 |
Input: n = 10
 8 | Output: 12
 9 | Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers.
10 | 11 |

Note:  

12 | 13 |
    14 |
  1. 1 is typically treated as an ugly number.
  2. 15 |
  3. n does not exceed 1690.
  4. 16 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/266.md: -------------------------------------------------------------------------------- 1 |

Given a string, determine if a permutation of the string could form a palindrome.

2 | 3 |

Example 1:

4 | 5 |
Input: "code"
 6 | Output: false
7 | 8 |

Example 2:

9 | 10 |
Input: "aab"
11 | Output: true
12 | 13 |

Example 3:

14 | 15 |
Input: "carerac"
16 | Output: true
17 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/267.md: -------------------------------------------------------------------------------- 1 |

Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form.

2 | 3 |

Example 1:

4 | 5 |
Input: "aabb"
 6 | Output: ["abba", "baab"]
7 | 8 |

Example 2:

9 | 10 |
Input: "abc"
11 | Output: []
12 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/270.md: -------------------------------------------------------------------------------- 1 |

Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.

2 | 3 |

Note:

4 | 5 |
    6 |
  • Given target value is a floating point.
  • 7 |
  • You are guaranteed to have only one unique value in the BST that is closest to the target.
  • 8 |
9 | 10 |

Example:

11 | 12 |
Input: root = [4,2,5,1,3], target = 3.714286
13 | 
14 |     4
15 |    / \
16 |   2   5
17 |  / \
18 | 1   3
19 | 
20 | Output: 4
21 | 
22 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/280.md: -------------------------------------------------------------------------------- 1 |

Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3]....

2 | 3 |

Example:

4 | 5 |
Input: nums = [3,5,2,1,6,4]
6 | Output: One possible answer is [3,5,1,6,2,4]
7 |
-------------------------------------------------------------------------------- /leetcode/desc/d2/283.md: -------------------------------------------------------------------------------- 1 |

Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.

2 | 3 |

Example:

4 | 5 |
Input: [0,1,0,3,12]
 6 | Output: [1,3,12,0,0]
7 | 8 |

Note:

9 | 10 |
    11 |
  1. You must do this in-place without making a copy of the array.
  2. 12 |
  3. Minimize the total number of operations.
  4. 13 |
-------------------------------------------------------------------------------- /leetcode/desc/d3/301.md: -------------------------------------------------------------------------------- 1 |

Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.

2 | 3 |

Note: The input string may contain letters other than the parentheses ( and ).

4 | 5 |

Example 1:

6 | 7 |
Input: "()())()"
 8 | Output: ["()()()", "(())()"]
 9 | 
10 | 11 |

Example 2:

12 | 13 |
Input: "(a)())()"
14 | Output: ["(a)()()", "(a())()"]
15 | 
16 | 17 |

Example 3:

18 | 19 |
Input: ")("
20 | Output: [""]
21 | 
-------------------------------------------------------------------------------- /leetcode/desc/d3/345.md: -------------------------------------------------------------------------------- 1 |

Write a function that takes a string as input and reverse only the vowels of a string.

2 | 3 |

Example 1:

4 | 5 |
Input: "hello"
 6 | Output: "holle"
 7 | 
8 | 9 |
10 |

Example 2:

11 | 12 |
Input: "leetcode"
13 | Output: "leotcede"
14 |
15 | 16 |

Note:
17 | The vowels does not include the letter "y".

18 | 19 |

 

20 |
-------------------------------------------------------------------------------- /leetcode/desc/d3/352.md: -------------------------------------------------------------------------------- 1 |

Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals.

2 | 3 |

For example, suppose the integers from the data stream are 1, 3, 7, 2, 6, ..., then the summary will be:

4 | 5 |
[1, 1]
 6 | [1, 1], [3, 3]
 7 | [1, 1], [3, 3], [7, 7]
 8 | [1, 3], [7, 7]
 9 | [1, 3], [6, 7]
10 | 
11 | 12 |

 

13 | 14 |

Follow up:

15 | 16 |

What if there are lots of merges and the number of disjoint intervals are small compared to the data stream's size?

17 |
-------------------------------------------------------------------------------- /leetcode/desc/d3/357.md: -------------------------------------------------------------------------------- 1 |

Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.

2 | 3 |
4 |

Example:

5 | 6 |
Input: 2
 7 | Output: 91 
 8 | Explanation: The answer should be the total numbers in the range of 0 ≤ x < 100, 
 9 |              excluding 11,22,33,44,55,66,77,88,99
10 | 
11 |
12 |

 

13 |

Constraints:

14 | 15 |
    16 |
  • 0 <= n <= 8
  • 17 |
18 |
-------------------------------------------------------------------------------- /leetcode/desc/d3/371.md: -------------------------------------------------------------------------------- 1 |

Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.

2 | 3 |
4 |

Example 1:

5 | 6 |
Input: a = 1, b = 2
 7 | Output: 3
 8 | 
9 | 10 |
11 |

Example 2:

12 | 13 |
Input: a = -2, b = 3
14 | Output: 1
15 | 
16 |
17 |
18 |
-------------------------------------------------------------------------------- /leetcode/desc/d3/378.md: -------------------------------------------------------------------------------- 1 |

Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.

2 | 3 |

4 | Note that it is the kth smallest element in the sorted order, not the kth distinct element. 5 |

6 | 7 |

Example: 8 |

matrix = [
 9 |    [ 1,  5,  9],
10 |    [10, 11, 13],
11 |    [12, 13, 15]
12 | ],
13 | k = 8,
14 | 
15 | return 13.
16 | 
17 |

18 | 19 |

Note:
20 | You may assume k is always valid, 1 ≤ k ≤ n2.

-------------------------------------------------------------------------------- /leetcode/desc/d3/386.md: -------------------------------------------------------------------------------- 1 |

Given an integer n, return 1 - n in lexicographical order.

2 | 3 |

For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9].

4 | 5 |

Please optimize your algorithm to use less time and space. The input size may be as large as 5,000,000.

6 |
-------------------------------------------------------------------------------- /leetcode/desc/d3/387.md: -------------------------------------------------------------------------------- 1 |

Given a string, find the first non-repeating character in it and return its index. If it doesn't exist, return -1.

2 | 3 |

Examples:

4 | 5 |
s = "leetcode"
 6 | return 0.
 7 | 
 8 | s = "loveleetcode"
 9 | return 2.
10 | 
11 | 12 |

 

13 | 14 |

Note: You may assume the string contains only lowercase English letters.

15 |
-------------------------------------------------------------------------------- /leetcode/desc/d4/400.md: -------------------------------------------------------------------------------- 1 |

Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...

2 | 3 |

Note:
4 | n is positive and will fit within the range of a 32-bit signed integer (n < 231). 5 |

6 | 7 |

Example 1: 8 |

Input:
 9 | 3
10 | 
11 | Output:
12 | 3
13 | 
14 |

15 | 16 |

Example 2: 17 |

Input:
18 | 11
19 | 
20 | Output:
21 | 0
22 | 
23 | Explanation:
24 | The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, which is part of the number 10.
25 | 
26 |

-------------------------------------------------------------------------------- /leetcode/desc/d4/404.md: -------------------------------------------------------------------------------- 1 |

Find the sum of all left leaves in a given binary tree.

2 | 3 |

Example: 4 |

    3
 5 |    / \
 6 |   9  20
 7 |     /  \
 8 |    15   7
 9 | 
10 | There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.
11 | 
12 |

-------------------------------------------------------------------------------- /leetcode/desc/d4/412.md: -------------------------------------------------------------------------------- 1 |

Write a program that outputs the string representation of numbers from 1 to n.

2 | 3 |

But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”.

4 | 5 |

Example: 6 |

n = 15,
 7 | 
 8 | Return:
 9 | [
10 |     "1",
11 |     "2",
12 |     "Fizz",
13 |     "4",
14 |     "Buzz",
15 |     "Fizz",
16 |     "7",
17 |     "8",
18 |     "Fizz",
19 |     "Buzz",
20 |     "11",
21 |     "Fizz",
22 |     "13",
23 |     "14",
24 |     "FizzBuzz"
25 | ]
26 | 
27 |

-------------------------------------------------------------------------------- /leetcode/desc/d4/415.md: -------------------------------------------------------------------------------- 1 |

Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.

2 | 3 |

Note: 4 |

    5 |
  1. The length of both num1 and num2 is < 5100.
  2. 6 |
  3. Both num1 and num2 contains only digits 0-9.
  4. 7 |
  5. Both num1 and num2 does not contain any leading zero.
  6. 8 |
  7. You must not use any built-in BigInteger library or convert the inputs to integer directly.
  8. 9 |
10 |

-------------------------------------------------------------------------------- /leetcode/desc/d4/440.md: -------------------------------------------------------------------------------- 1 |

Given integers n and k, find the lexicographically k-th smallest integer in the range from 1 to n.

2 | 3 |

Note: 1 ≤ k ≤ n ≤ 109.

4 | 5 |

Example: 6 |

Input:
 7 | n: 13   k: 2
 8 | 
 9 | Output:
10 | 10
11 | 
12 | Explanation:
13 | The lexicographical order is [1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9], so the second smallest number is 10.
14 | 
15 |

16 |
-------------------------------------------------------------------------------- /leetcode/desc/d4/442.md: -------------------------------------------------------------------------------- 1 |

Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

2 | 3 |

Find all the elements that appear twice in this array.

4 | 5 |

Could you do it without extra space and in O(n) runtime?

6 |

7 |

Example:
8 |

Input:
 9 | [4,3,2,7,8,2,3,1]
10 | 
11 | Output:
12 | [2,3]
13 | 
-------------------------------------------------------------------------------- /leetcode/desc/d4/445.md: -------------------------------------------------------------------------------- 1 |

You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

2 | 3 |

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

4 | 5 |

Follow up:
6 | What if you cannot modify the input lists? In other words, reversing the lists is not allowed. 7 |

8 | 9 |

10 | Example: 11 |

Input: (7 -> 2 -> 4 -> 3) + (5 -> 6 -> 4)
12 | Output: 7 -> 8 -> 0 -> 7
13 | 
14 |

-------------------------------------------------------------------------------- /leetcode/desc/d4/448.md: -------------------------------------------------------------------------------- 1 |

Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

2 | 3 |

Find all the elements of [1, n] inclusive that do not appear in this array.

4 | 5 |

Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space.

6 | 7 |

Example: 8 |

Input:
 9 | [4,3,2,7,8,2,3,1]
10 | 
11 | Output:
12 | [5,6]
13 | 
14 |

-------------------------------------------------------------------------------- /leetcode/desc/d4/453.md: -------------------------------------------------------------------------------- 1 |

Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.

2 | 3 |

Example: 4 |

Input:
 5 | [1,2,3]
 6 | 
 7 | Output:
 8 | 3
 9 | 
10 | Explanation:
11 | Only three moves are needed (remember each move increments two elements):
12 | 
13 | [1,2,3]  =>  [2,3,3]  =>  [3,4,3]  =>  [4,4,4]
14 | 
15 |

-------------------------------------------------------------------------------- /leetcode/desc/d4/462.md: -------------------------------------------------------------------------------- 1 |

Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected element by 1.

2 | 3 |

You may assume the array's length is at most 10,000.

4 | 5 |

Example: 6 |

Input:
 7 | [1,2,3]
 8 | 
 9 | Output:
10 | 2
11 | 
12 | Explanation:
13 | Only two moves are needed (remember each move increments or decrements one element):
14 | 
15 | [1,2,3]  =>  [2,2,3]  =>  [2,2,2]
16 | 
17 |

-------------------------------------------------------------------------------- /leetcode/desc/d4/479.md: -------------------------------------------------------------------------------- 1 |

Find the largest palindrome made from the product of two n-digit numbers.

2 | 3 |

Since the result could be very large, you should return the largest palindrome mod 1337.

4 | 5 |

 

6 | 7 |

Example:

8 | 9 |

Input: 2

10 | 11 |

Output: 987

12 | 13 |

Explanation: 99 x 91 = 9009, 9009 % 1337 = 987

14 | 15 |

 

16 | 17 |

Note:

18 | 19 |

The range of n is [1,8].

20 |
-------------------------------------------------------------------------------- /leetcode/desc/d4/485.md: -------------------------------------------------------------------------------- 1 |

Given a binary array, find the maximum number of consecutive 1s in this array.

2 | 3 |

Example 1:
4 |

Input: [1,1,0,1,1,1]
 5 | Output: 3
 6 | Explanation: The first two digits or the last three digits are consecutive 1s.
 7 |     The maximum number of consecutive 1s is 3.
 8 | 
9 |

10 | 11 |

Note: 12 |

    13 |
  • The input array will only contain 0 and 1.
  • 14 |
  • The length of input array is a positive integer and will not exceed 10,000
  • 15 |
16 |

-------------------------------------------------------------------------------- /leetcode/desc/d4/498.md: -------------------------------------------------------------------------------- 1 |

Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image.

2 | 3 |

 

4 | 5 |

Example:

6 | 7 |
Input:
 8 | [
 9 |  [ 1, 2, 3 ],
10 |  [ 4, 5, 6 ],
11 |  [ 7, 8, 9 ]
12 | ]
13 | 
14 | Output:  [1,2,4,7,5,3,6,8,9]
15 | 
16 | Explanation:
17 | 
18 | 
19 | 20 |

 

21 | 22 |

Note:

23 | 24 |

The total number of elements of the given matrix will not exceed 10,000.

25 |
-------------------------------------------------------------------------------- /leetcode/desc/d5/504.md: -------------------------------------------------------------------------------- 1 |

Given an integer, return its base 7 string representation.

2 | 3 |

Example 1:
4 |

Input: 100
 5 | Output: "202"
 6 | 
7 |

8 | 9 |

Example 2:
10 |

Input: -7
11 | Output: "-10"
12 | 
13 |

14 | 15 |

Note: 16 | The input will be in range of [-1e7, 1e7]. 17 |

-------------------------------------------------------------------------------- /leetcode/desc/d5/525.md: -------------------------------------------------------------------------------- 1 |

Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.

2 | 3 | 4 |

Example 1:
5 |

Input: [0,1]
 6 | Output: 2
 7 | Explanation: [0, 1] is the longest contiguous subarray with equal number of 0 and 1.
 8 | 
9 |

10 | 11 |

Example 2:
12 |

Input: [0,1,0]
13 | Output: 2
14 | Explanation: [0, 1] (or [1, 0]) is a longest contiguous subarray with equal number of 0 and 1.
15 | 
16 |

17 | 18 |

Note: 19 | The length of the given binary array will not exceed 50,000. 20 |

-------------------------------------------------------------------------------- /leetcode/desc/d5/557.md: -------------------------------------------------------------------------------- 1 |

Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.

2 | 3 |

Example 1:
4 |

Input: "Let's take LeetCode contest"
 5 | Output: "s'teL ekat edoCteeL tsetnoc"
 6 | 
7 |

8 | 9 |

Note: 10 | In the string, each word is separated by single space and there will not be any extra space in the string. 11 |

-------------------------------------------------------------------------------- /leetcode/desc/d5/562.md: -------------------------------------------------------------------------------- 1 |
Given a 01 matrix M, find the longest line of consecutive one in the matrix. The line could be horizontal, vertical, diagonal or anti-diagonal. 2 | 3 |

Example:
4 |

Input:
 5 | [[0,1,1,0],
 6 |  [0,1,1,0],
 7 |  [0,0,0,1]]
 8 | Output: 3
 9 | 
10 |

11 | 12 |

13 | Hint: 14 | The number of elements in the given matrix will not exceed 10,000. 15 |

-------------------------------------------------------------------------------- /leetcode/desc/d5/564.md: -------------------------------------------------------------------------------- 1 |

Given an integer n, find the closest integer (not including itself), which is a palindrome.

2 | 3 |

The 'closest' is defined as absolute difference minimized between two integers.

4 | 5 |

Example 1:
6 |

Input: "123"
 7 | Output: "121"
 8 | 
9 |

10 | 11 |

Note:
12 |

    13 |
  1. The input n is a positive integer represented by string, whose length will not exceed 18.
  2. 14 |
  3. If there is a tie, return the smaller one as answer.
  4. 15 |
16 |

-------------------------------------------------------------------------------- /leetcode/desc/d5/583.md: -------------------------------------------------------------------------------- 1 |

2 | Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one character in either string. 3 |

4 | 5 |

Example 1:
6 |

Input: "sea", "eat"
 7 | Output: 2
 8 | Explanation: You need one step to make "sea" to "ea" and another step to make "eat" to "ea".
 9 | 
10 |

11 | 12 |

Note:
13 |

    14 |
  1. The length of given words won't exceed 500.
  2. 15 |
  3. Characters in given words can only be lower-case letters.
  4. 16 |
17 |

-------------------------------------------------------------------------------- /leetcode/desc/d6/611.md: -------------------------------------------------------------------------------- 1 |
Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. 2 | 3 |

Example 1:
4 |

Input: [2,2,3,4]
 5 | Output: 3
 6 | Explanation:
 7 | Valid combinations are: 
 8 | 2,3,4 (using the first 2)
 9 | 2,3,4 (using the second 2)
10 | 2,2,3
11 | 
12 |

13 | 14 |

Note:
15 |

    16 |
  1. The length of the given array won't exceed 1000.
  2. 17 |
  3. The integers in the given array are in the range of [0, 1000].
  4. 18 |
19 |

20 |
-------------------------------------------------------------------------------- /leetcode/desc/d6/625.md: -------------------------------------------------------------------------------- 1 |

Given a positive integer a, find the smallest positive integer b whose multiplication of each digit equals to a.

2 | 3 |

4 | If there is no answer or the answer is not fit in 32-bit signed integer, then return 0.

5 | 6 |

7 | Example 1
8 | Input: 9 |

48 
10 | Output: 11 |
68
12 |

13 | 14 |

15 | Example 2
16 | Input: 17 |

15
18 | 19 | Output: 20 |
35
21 |

-------------------------------------------------------------------------------- /leetcode/desc/d6/637.md: -------------------------------------------------------------------------------- 1 |
Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. 2 | 3 |

Example 1:
4 |

Input:
 5 |     3
 6 |    / \
 7 |   9  20
 8 |     /  \
 9 |    15   7
10 | Output: [3, 14.5, 11]
11 | Explanation:
12 | The average value of nodes on level 0 is 3,  on level 1 is 14.5, and on level 2 is 11. Hence return [3, 14.5, 11].
13 | 
14 |

15 | 16 |

Note:
17 |

    18 |
  1. The range of node's value is in the range of 32-bit signed integer.
  2. 19 |
20 |

-------------------------------------------------------------------------------- /leetcode/desc/d6/643.md: -------------------------------------------------------------------------------- 1 |

Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value.

2 | 3 |

Example 1:

4 | 5 |
Input: [1,12,-5,-6,50,3], k = 4
 6 | Output: 12.75
 7 | Explanation: Maximum average is (12-5-6+50)/4 = 51/4 = 12.75
 8 | 
9 | 10 |

 

11 | 12 |

Note:

13 | 14 |
    15 |
  1. 1 <= k <= n <= 30,000.
  2. 16 |
  3. Elements of the given array will be in the range [-10,000, 10,000].
  4. 17 |
18 | 19 |

 

20 |
-------------------------------------------------------------------------------- /leetcode/desc/d6/660.md: -------------------------------------------------------------------------------- 1 |

Start from integer 1, remove any integer that contains 9 such as 9, 19, 29...

2 | 3 |

So now, you will have a new integer sequence: 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, ...

4 | 5 |

Given a positive integer n, you need to return the n-th integer after removing. Note that 1 will be the first integer.

6 | 7 |

 

8 |

Example 1:

9 |
Input: n = 9
10 | Output: 10
11 | 
12 |

 

13 |

Constraints:

14 | 15 |
    16 |
  • 1 <= n <= 8 x 10^8
  • 17 |
18 |
-------------------------------------------------------------------------------- /leetcode/desc/d6/670.md: -------------------------------------------------------------------------------- 1 |

2 | Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get. 3 |

4 | 5 |

Example 1:
6 |

Input: 2736
 7 | Output: 7236
 8 | Explanation: Swap the number 2 and the number 7.
 9 | 
10 |

11 | 12 |

Example 2:
13 |

Input: 9973
14 | Output: 9973
15 | Explanation: No swap.
16 | 
17 |

18 | 19 | 20 |

Note:
21 |

    22 |
  1. The given number is in the range [0, 108]
  2. 23 |
24 |

-------------------------------------------------------------------------------- /leetcode/desc/d6/680.md: -------------------------------------------------------------------------------- 1 |

2 | Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. 3 |

4 | 5 |

Example 1:
6 |

Input: "aba"
 7 | Output: True
 8 | 
9 |

10 | 11 |

Example 2:
12 |

Input: "abca"
13 | Output: True
14 | Explanation: You could delete the character 'c'.
15 | 
16 |

17 | 18 |

Note:
19 |

    20 |
  1. The string will only contain lowercase characters a-z. 21 | The maximum length of the string is 50000.
  2. 22 |
23 |

-------------------------------------------------------------------------------- /leetcode/desc/d7/718.md: -------------------------------------------------------------------------------- 1 |

Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.

2 | 3 |

Example 1:

4 | 5 |
Input:
 6 | A: [1,2,3,2,1]
 7 | B: [3,2,1,4,7]
 8 | Output: 3
 9 | Explanation: 
10 | The repeated subarray with maximum length is [3, 2, 1].
11 | 
12 | 13 |

 

14 | 15 |

Note:

16 | 17 |
    18 |
  1. 1 <= len(A), len(B) <= 1000
  2. 19 |
  3. 0 <= A[i], B[i] < 100
  4. 20 |
21 | 22 |

 

23 |
-------------------------------------------------------------------------------- /leetcode/desc/d7/739.md: -------------------------------------------------------------------------------- 1 |

2 | Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead. 3 |

4 | For example, given the list of temperatures T = [73, 74, 75, 71, 69, 72, 76, 73], your output should be [1, 1, 4, 2, 1, 1, 0, 0]. 5 |

6 | 7 |

Note: 8 | The length of temperatures will be in the range [1, 30000]. 9 | Each temperature will be an integer in the range [30, 100]. 10 |

-------------------------------------------------------------------------------- /leetcode/desc/d9/912.md: -------------------------------------------------------------------------------- 1 |

Given an array of integers nums, sort the array in ascending order.

2 | 3 |

 

4 |

Example 1:

5 |
Input: nums = [5,2,3,1]
 6 | Output: [1,2,3,5]
 7 | 

Example 2:

8 |
Input: nums = [5,1,1,2,0,0]
 9 | Output: [0,0,1,1,2,5]
10 | 
11 |

 

12 |

Constraints:

13 | 14 |
    15 |
  • 1 <= nums.length <= 50000
  • 16 |
  • -50000 <= nums[i] <= 50000
  • 17 |
18 |
-------------------------------------------------------------------------------- /leetcode/src/d0/_11_container_with_most_water.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn max_area(height: Vec) -> i32 { 5 | let mut max = 0; 6 | let mut l = 0; 7 | let mut r = height.len() - 1; 8 | while l < r { 9 | max = i32::max(i32::min(height[l], height[r]) * (r - l) as i32, max); 10 | if height[l] < height[r] { 11 | l += 1; 12 | } else { 13 | r -= 1; 14 | } 15 | } 16 | max 17 | } 18 | } 19 | 20 | #[test] 21 | fn test() { 22 | let height = vec![1, 8, 6, 2, 5, 4, 8, 3, 7]; 23 | assert_eq!(Solution::max_area(height), 49); 24 | } 25 | -------------------------------------------------------------------------------- /leetcode/src/d0/_28_implement_str_str.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn str_str(haystack: String, needle: String) -> i32 { 5 | match haystack.find(&needle) { 6 | Some(index) => index as i32, 7 | None => -1, 8 | } 9 | } 10 | } 11 | 12 | #[test] 13 | fn test() { 14 | assert_eq!(Solution::str_str("hello".to_string(), "ll".to_string()), 2); 15 | assert_eq!( 16 | Solution::str_str("aaaaa".to_string(), "bba".to_string()), 17 | -1 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d0/_45_jump_game_2.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn jump(nums: Vec) -> i32 { 5 | let n = nums.len(); 6 | let mut end = 0; 7 | let mut max = 0; 8 | let mut res = 0; 9 | for i in 0..n - 1 { 10 | max = max.max(i + nums[i] as usize); 11 | if i == end { 12 | res += 1; 13 | end = max; 14 | } 15 | } 16 | res 17 | } 18 | } 19 | 20 | #[test] 21 | fn test() { 22 | let nums = vec![2, 3, 1, 1, 4]; 23 | let res = 2; 24 | assert_eq!(Solution::jump(nums), res); 25 | } 26 | -------------------------------------------------------------------------------- /leetcode/src/d0/_50_pow_x_n.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn my_pow(x: f64, n: i32) -> f64 { 5 | x.powi(n) 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | use assert_approx_eq::assert_approx_eq; 12 | assert_approx_eq!(Solution::my_pow(2.0, 10), 1024.0); 13 | assert_approx_eq!(Solution::my_pow(2.0, -3), 0.125); 14 | assert_approx_eq!(Solution::my_pow(1.0, -2_147_483_648), 1.0); 15 | } 16 | -------------------------------------------------------------------------------- /leetcode/src/d0/_55_jump_game.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn can_jump(nums: Vec) -> bool { 5 | let n = nums.len(); 6 | let mut last = n - 1; 7 | for i in (0..n).rev() { 8 | if i + nums[i] as usize >= last { 9 | last = i; 10 | } 11 | } 12 | last == 0 13 | } 14 | } 15 | 16 | #[test] 17 | fn test() { 18 | let nums = vec![2, 3, 1, 1, 4]; 19 | let res = true; 20 | assert_eq!(Solution::can_jump(nums), res); 21 | let nums = vec![3, 2, 1, 0, 4]; 22 | let res = false; 23 | assert_eq!(Solution::can_jump(nums), res); 24 | } 25 | -------------------------------------------------------------------------------- /leetcode/src/d0/_58_length_of_last_word.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn length_of_last_word(s: String) -> i32 { 5 | if let Some(last) = s.split_whitespace().last() { 6 | last.len() as i32 7 | } else { 8 | 0 9 | } 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | assert_eq!( 16 | Solution::length_of_last_word(String::from("Hello World")), 17 | 5 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d0/_66_plus_one.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn plus_one(digits: Vec) -> Vec { 5 | let mut sum: Vec = vec![]; 6 | let mut carry: i32 = 0; 7 | for (i, d) in digits.iter().rev().enumerate() { 8 | let x = if i == 0 { d + 1 } else { d + carry }; 9 | carry = x / 10; 10 | sum.insert(0, x % 10); 11 | } 12 | if carry != 0 { 13 | sum.insert(0, carry); 14 | } 15 | sum 16 | } 17 | } 18 | 19 | #[test] 20 | fn test() { 21 | assert_eq!(Solution::plus_one(vec![9, 9, 9]), vec![1, 0, 0, 0]) 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d0/_67_add_binary.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn add_binary(a: String, b: String) -> String { 5 | let aa = i128::from_str_radix(&a, 2).unwrap_or(0); 6 | let bb = i128::from_str_radix(&b, 2).unwrap_or(0); 7 | format!("{:b}", aa + bb) 8 | } 9 | } 10 | 11 | #[test] 12 | fn test() { 13 | assert_eq!( 14 | Solution::add_binary("1010".to_string(), "1011".to_string()), 15 | "10101".to_string() 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /leetcode/src/d0/_69_sqrt.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn my_sqrt(x: i32) -> i32 { 5 | (x as f64).sqrt().floor() as i32 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | assert_eq!(Solution::my_sqrt(8), 2); 12 | } 13 | -------------------------------------------------------------------------------- /leetcode/src/d0/_70_climbing_stairs.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn climb_stairs(n: i32) -> i32 { 5 | match n { 6 | 1 | 2 => n, 7 | k => (2..k).fold((1, 2), |acc, _| (acc.1, acc.0 + acc.1)).1, 8 | } 9 | } 10 | } 11 | 12 | #[test] 13 | fn test() { 14 | assert_eq!(Solution::climb_stairs(3), 3); 15 | assert_eq!(Solution::climb_stairs(2), 2); 16 | assert_eq!(Solution::climb_stairs(1), 1); 17 | } 18 | -------------------------------------------------------------------------------- /leetcode/src/d0/_74_search_a_2d_matrix.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn search_matrix(matrix: Vec>, target: i32) -> bool { 5 | let mut a = vec![]; 6 | for row in matrix { 7 | for x in row { 8 | a.push(x); 9 | } 10 | } 11 | a.binary_search(&target).is_ok() 12 | } 13 | } 14 | 15 | #[test] 16 | fn test() { 17 | let matrix: Vec> = vec_vec_i32![[1, 3, 5, 7], [10, 11, 16, 20], [23, 30, 34, 50]]; 18 | let target = 3; 19 | let res = true; 20 | assert_eq!(Solution::search_matrix(matrix, target), res); 21 | } 22 | -------------------------------------------------------------------------------- /leetcode/src/d0/_88_merge_sorted_array.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn merge(nums1: &mut Vec, m: i32, nums2: &mut Vec, n: i32) { 5 | nums1.truncate(m as usize); 6 | nums2.truncate(n as usize); 7 | nums1.append(nums2); 8 | nums1.sort_unstable(); 9 | } 10 | } 11 | 12 | #[test] 13 | fn test() { 14 | let mut nums1 = vec![1, 2, 3, 0, 0, 0]; 15 | let mut nums2 = vec![2, 5, 6]; 16 | let m = 3; 17 | let n = 3; 18 | Solution::merge(&mut nums1, m, &mut nums2, n); 19 | assert_eq!(nums1, vec![1, 2, 2, 3, 5, 6]); 20 | } 21 | -------------------------------------------------------------------------------- /leetcode/src/d0/_89_gray_code.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn gray_code(n: i32) -> Vec { 5 | let mut res = vec![]; 6 | for i in 0..(1 << n) { 7 | res.push(i ^ i >> 1); 8 | } 9 | res 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | let n = 2; 16 | let res = vec![0, 1, 3, 2]; 17 | assert_eq!(Solution::gray_code(n), res); 18 | } 19 | -------------------------------------------------------------------------------- /leetcode/src/d0/_96_unique_binary_search_trees.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn num_trees(n: i32) -> i32 { 5 | let n = n as usize; 6 | let mut dp: Vec = vec![0; n + 1]; 7 | dp[0] = 1; 8 | dp[1] = 1; 9 | for i in 2..=n { 10 | for j in 0..i { 11 | dp[i] += dp[j] * dp[i - 1 - j]; 12 | } 13 | } 14 | dp[n] 15 | } 16 | } 17 | 18 | #[test] 19 | fn test() { 20 | let n = 3; 21 | let res = 5; 22 | assert_eq!(Solution::num_trees(n), res); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d1/_100_same_tree.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | use rustgym_util::*; 3 | 4 | impl Solution { 5 | fn is_same_tree(p: TreeLink, q: TreeLink) -> bool { 6 | p == q 7 | } 8 | } 9 | 10 | #[test] 11 | fn test() { 12 | let q = tree!( 13 | 1, 14 | tree!(2, tree!(1), tree!(1)), 15 | tree!(2, tree!(1), tree!(1)) 16 | ); 17 | let p = tree!( 18 | 1, 19 | tree!(2, tree!(1), tree!(1)), 20 | tree!(2, tree!(1), tree!(1)) 21 | ); 22 | let res = true; 23 | assert_eq!(Solution::is_same_tree(p, q), res); 24 | } 25 | -------------------------------------------------------------------------------- /leetcode/src/d1/_120_triangle.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn minimum_total(triangle: Vec>) -> i32 { 5 | let n = triangle.len(); 6 | let mut dp = vec![vec![0; n + 1]; 2]; 7 | for i in (0..n).rev() { 8 | for j in 0..=i { 9 | dp[i % 2][j] = triangle[i][j] + dp[(i + 1) % 2][j].min(dp[(i + 1) % 2][j + 1]); 10 | } 11 | } 12 | dp[0][0] 13 | } 14 | } 15 | 16 | #[test] 17 | fn test() { 18 | let triangle = vec_vec_i32![[2], [3, 4], [6, 5, 7], [4, 1, 8, 3]]; 19 | let res = 11; 20 | assert_eq!(Solution::minimum_total(triangle), res); 21 | } 22 | -------------------------------------------------------------------------------- /leetcode/src/d1/_121_best_time_to_buy_and_sell_stock.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn max_profit(prices: Vec) -> i32 { 5 | let mut cost = std::i32::MAX; 6 | let mut profit = 0; 7 | for price in prices { 8 | profit = profit.max(price - cost); 9 | cost = cost.min(price); 10 | } 11 | profit 12 | } 13 | } 14 | 15 | #[test] 16 | fn test() { 17 | let prices = vec![7, 1, 5, 3, 6, 4]; 18 | let res = 5; 19 | assert_eq!(Solution::max_profit(prices), res); 20 | let prices = vec![7, 6, 4, 3, 1]; 21 | let res = 0; 22 | assert_eq!(Solution::max_profit(prices), res); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d1/_122_best_time_to_buy_and_sell_stock_2.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn max_profit(prices: Vec) -> i32 { 5 | let mut max = 0; 6 | for i in 1..prices.len() { 7 | if prices[i] > prices[i - 1] { 8 | max += prices[i] - prices[i - 1] 9 | } 10 | } 11 | max 12 | } 13 | } 14 | 15 | #[test] 16 | fn test() { 17 | assert_eq!(Solution::max_profit(vec![7, 1, 5, 3, 6, 4]), 7); 18 | assert_eq!(Solution::max_profit(vec![1, 2, 3, 4, 5]), 4); 19 | assert_eq!(Solution::max_profit(vec![7, 6, 4, 3, 1]), 0); 20 | } 21 | -------------------------------------------------------------------------------- /leetcode/src/d1/_136_single_number.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn single_number(nums: Vec) -> i32 { 5 | nums.iter().fold(0i32, |res, val| res ^ val) 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | assert_eq!(Solution::single_number(vec![2, 2, 1]), 1); 12 | assert_eq!(Solution::single_number(vec![4, 1, 2, 1, 2]), 4); 13 | } 14 | -------------------------------------------------------------------------------- /leetcode/src/d1/_137_single_number_2.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn single_number(nums: Vec) -> i32 { 5 | let mut once = 0; 6 | let mut twice = 0; 7 | for x in nums { 8 | once = !twice & (once ^ x); 9 | twice = !once & (twice ^ x); 10 | } 11 | once 12 | } 13 | } 14 | 15 | #[test] 16 | fn test() { 17 | let nums = vec![2, 2, 3, 2]; 18 | let res = 3; 19 | assert_eq!(Solution::single_number(nums), res); 20 | let nums = vec![0, 1, 0, 1, 0, 1, 99]; 21 | let res = 99; 22 | assert_eq!(Solution::single_number(nums), res); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d1/_151_reverse_words_in_a_string.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn reverse_words(s: String) -> String { 5 | s.split_whitespace().rev().collect::>().join(" ") 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | let s: String = "the sky is blue".to_string(); 12 | let res: String = "blue is sky the".to_string(); 13 | assert_eq!(Solution::reverse_words(s), res); 14 | } 15 | -------------------------------------------------------------------------------- /leetcode/src/d1/_164_maximum_gap.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn maximum_gap(mut nums: Vec) -> i32 { 5 | let n = nums.len(); 6 | nums.sort_unstable(); 7 | let mut res = 0; 8 | for i in 1..n { 9 | res = res.max(nums[i] - nums[i - 1]); 10 | } 11 | res 12 | } 13 | } 14 | 15 | #[test] 16 | fn test() { 17 | let nums = vec![3, 6, 9, 1]; 18 | let res = 3; 19 | assert_eq!(Solution::maximum_gap(nums), res); 20 | } 21 | -------------------------------------------------------------------------------- /leetcode/src/d1/_168_excel_sheet_column_title.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn convert_to_title(mut n: i32) -> String { 5 | let mut v: Vec = vec![]; 6 | while n > 0 { 7 | let x = ((n - 1) % 26) as u8; 8 | let c = (x + b'A') as char; 9 | v.insert(0, c); 10 | n = (n - 1) / 26; 11 | } 12 | v.iter().collect() 13 | } 14 | } 15 | 16 | #[test] 17 | fn test() { 18 | assert_eq!(Solution::convert_to_title(701), "ZY".to_string()); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d1/_171_excel_sheet_column_number.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn title_to_number(s: String) -> i32 { 5 | s.bytes() 6 | .fold(0, |sum, c| sum * 26 + i32::from(c) - 'A' as i32 + 1) 7 | } 8 | } 9 | 10 | #[test] 11 | fn test() { 12 | assert_eq!(Solution::title_to_number("A".to_string()), 1); 13 | assert_eq!(Solution::title_to_number("AB".to_string()), 28); 14 | assert_eq!(Solution::title_to_number("ZY".to_string()), 701); 15 | } 16 | -------------------------------------------------------------------------------- /leetcode/src/d1/_172_factorial_trailing_zeroes.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn trailing_zeroes(mut n: i32) -> i32 { 5 | let mut sum = 0; 6 | while n > 0 { 7 | sum += n / 5; 8 | n /= 5; 9 | } 10 | sum 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | assert_eq!(Solution::trailing_zeroes(3), 0); 17 | assert_eq!(Solution::trailing_zeroes(5), 1); 18 | assert_eq!(Solution::trailing_zeroes(10), 2); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d1/_186_reverse_words_in_a_string_2.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn reverse_words(s: &mut Vec) { 5 | s.reverse(); 6 | for word in s.split_mut(|&c| c == ' ') { 7 | word.reverse(); 8 | } 9 | } 10 | } 11 | 12 | #[test] 13 | fn test() { 14 | let mut s = vec![ 15 | 't', 'h', 'e', ' ', 's', 'k', 'y', ' ', 'i', 's', ' ', 'b', 'l', 'u', 'e', 16 | ]; 17 | let res = vec![ 18 | 'b', 'l', 'u', 'e', ' ', 'i', 's', ' ', 's', 'k', 'y', ' ', 't', 'h', 'e', 19 | ]; 20 | Solution::reverse_words(&mut s); 21 | assert_eq!(s, res); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d1/_189_rotate_array.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn rotate(nums: &mut Vec, k: i32) { 5 | let k = k as usize % nums.len(); 6 | nums[..].reverse(); 7 | nums[0..k].reverse(); 8 | nums[k..].reverse(); 9 | // nums.rotate_right(k); 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | let mut nums = vec![1, 2, 3, 4, 5, 6, 7]; 16 | Solution::rotate(&mut nums, 3); 17 | assert_eq!(nums, vec![5, 6, 7, 1, 2, 3, 4]); 18 | } 19 | -------------------------------------------------------------------------------- /leetcode/src/d1/_191_number_of_1_bits.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::unreadable_literal)] 2 | struct Solution; 3 | 4 | impl Solution { 5 | #[allow(non_snake_case)] 6 | fn hammingWeight(n: u32) -> i32 { 7 | n.count_ones() as i32 8 | } 9 | } 10 | 11 | #[test] 12 | fn test() { 13 | let n = 0b00000000000000000000000000001011; 14 | let res = 3; 15 | assert_eq!(Solution::hammingWeight(n), res); 16 | let n = 0b00000000000000000000000010000000; 17 | let res = 1; 18 | assert_eq!(Solution::hammingWeight(n), res); 19 | let n = 0b11111111111111111111111111111101; 20 | let res = 31; 21 | assert_eq!(Solution::hammingWeight(n), res); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d10/_1006_clumsy_factorial.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn clumsy(n: i32) -> i32 { 5 | let magic = vec![1, 2, 2, -1, 0, 0, 3, 3]; 6 | n + if n > 4 { 7 | magic[(n % 4) as usize] 8 | } else { 9 | magic[(n + 3) as usize] 10 | } 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | let n = 4; 17 | let res = 7; 18 | assert_eq!(Solution::clumsy(n), res); 19 | let n = 10; 20 | let res = 12; 21 | assert_eq!(Solution::clumsy(n), res); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d10/_1009_complement_of_base_10_integer.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn bitwise_complement(n: i32) -> i32 { 5 | if n == 0 { 6 | return 1; 7 | } 8 | let mut mask = !0; 9 | while mask & n != 0 { 10 | mask <<= 1; 11 | } 12 | mask = !mask; 13 | mask ^ n 14 | } 15 | } 16 | 17 | #[test] 18 | fn test() { 19 | assert_eq!(Solution::bitwise_complement(5), 2); 20 | assert_eq!(Solution::bitwise_complement(7), 0); 21 | assert_eq!(Solution::bitwise_complement(10), 5); 22 | assert_eq!(Solution::bitwise_complement(0), 1); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d10/_1025_divisor_game.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn divisor_game(n: i32) -> bool { 5 | n % 2 == 0 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | assert_eq!(Solution::divisor_game(2), true); 12 | assert_eq!(Solution::divisor_game(3), false); 13 | } 14 | -------------------------------------------------------------------------------- /leetcode/src/d10/_1029_two_city_scheduling.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn two_city_sched_cost(costs: Vec>) -> i32 { 5 | let n = costs.len(); 6 | let mut diffs: Vec = costs.iter().map(|v| v[0] - v[1]).collect(); 7 | diffs.sort_unstable(); 8 | let sum_of_b: i32 = costs.iter().map(|v| v[1]).sum(); 9 | let sum_of_diff: i32 = diffs.iter().take(n / 2).sum(); 10 | sum_of_b + sum_of_diff 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | let costs: Vec> = vec_vec_i32![[10, 20], [30, 200], [400, 50], [30, 20]]; 17 | assert_eq!(Solution::two_city_sched_cost(costs), 110); 18 | } 19 | -------------------------------------------------------------------------------- /leetcode/src/d10/_1037_valid_boomerang.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn is_boomerang(points: Vec>) -> bool { 5 | points[0][0] * (points[1][1] - points[2][1]) 6 | + points[1][0] * (points[2][1] - points[0][1]) 7 | + points[2][0] * (points[0][1] - points[1][1]) 8 | != 0 9 | } 10 | } 11 | 12 | #[test] 13 | fn test() { 14 | let points: Vec> = vec_vec_i32![[1, 1], [2, 3], [3, 2]]; 15 | assert_eq!(Solution::is_boomerang(points), true); 16 | let points: Vec> = vec_vec_i32![[1, 1], [2, 2], [3, 3]]; 17 | assert_eq!(Solution::is_boomerang(points), false); 18 | } 19 | -------------------------------------------------------------------------------- /leetcode/src/d10/_1051_height_checker.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn height_checker(heights: Vec) -> i32 { 5 | let mut sorted = heights.to_vec(); 6 | sorted.sort_unstable(); 7 | heights 8 | .iter() 9 | .zip(sorted.iter()) 10 | .fold(0, |sum, (a, b)| if a != b { sum + 1 } else { sum }) 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | let heights = vec![1, 1, 4, 2, 1, 3]; 17 | assert_eq!(Solution::height_checker(heights), 3); 18 | } 19 | -------------------------------------------------------------------------------- /leetcode/src/d10/_1064_fixed_point.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn fixed_point(a: Vec) -> i32 { 5 | for i in 0..a.len() { 6 | if i as i32 == a[i] { 7 | return i as i32; 8 | } 9 | } 10 | -1 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | assert_eq!(Solution::fixed_point(vec![-10, -5, 0, 3, 7]), 3); 17 | assert_eq!(Solution::fixed_point(vec![0, 2, 5, 8, 17]), 0); 18 | assert_eq!(Solution::fixed_point(vec![-10, -5, 3, 4, 7, 9]), -1); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d11/_1108_defanging_an_ip_address.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn defang_i_paddr(address: String) -> String { 5 | address.replace(".", "[.]") 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | let address = "1.1.1.1".to_string(); 12 | let res = "1[.]1[.]1[.]1".to_string(); 13 | assert_eq!(Solution::defang_i_paddr(address), res); 14 | let address = "255.100.50.0".to_string(); 15 | let res = "255[.]100[.]50[.]0".to_string(); 16 | assert_eq!(Solution::defang_i_paddr(address), res); 17 | } 18 | -------------------------------------------------------------------------------- /leetcode/src/d11/_1119_remove_vowels_from_a_string.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn remove_vowels(s: String) -> String { 5 | s.chars() 6 | .filter(|&c| !matches!(c, 'a' | 'e' | 'i' | 'o' | 'u')) 7 | .collect() 8 | } 9 | } 10 | 11 | #[test] 12 | fn test() { 13 | let s = "leetcodeisacommunityforcoders".to_string(); 14 | let t = "ltcdscmmntyfrcdrs".to_string(); 15 | assert_eq!(Solution::remove_vowels(s), t); 16 | } 17 | -------------------------------------------------------------------------------- /leetcode/src/d11/_1134_armstrong_number.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn is_armstrong(n: i32) -> bool { 5 | let mut x = n; 6 | let mut k = 0; 7 | let mut digits: Vec = vec![]; 8 | while x > 0 { 9 | let d = x % 10; 10 | digits.push(d); 11 | x /= 10; 12 | k += 1; 13 | } 14 | let sum: i32 = digits.iter().map(|x| x.pow(k)).sum(); 15 | sum == n 16 | } 17 | } 18 | 19 | #[test] 20 | fn test() { 21 | assert_eq!(Solution::is_armstrong(153), true); 22 | assert_eq!(Solution::is_armstrong(123), false); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d11/_1137_n_th_tribonacci_number.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn tribonacci(n: i32) -> i32 { 5 | let n = n as usize; 6 | let mut a: Vec = vec![0; 38]; 7 | a[0] = 0; 8 | a[1] = 1; 9 | a[2] = 1; 10 | for i in 3..=n { 11 | a[i] = a[i - 1] + a[i - 2] + a[i - 3]; 12 | } 13 | a[n] 14 | } 15 | } 16 | 17 | #[test] 18 | fn test() { 19 | assert_eq!(Solution::tribonacci(25), 1_389_537); 20 | } 21 | -------------------------------------------------------------------------------- /leetcode/src/d12/_1227_airplane_seat_assignment_probability.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn nth_person_gets_nth_seat(n: i32) -> f64 { 5 | if n > 1 { 6 | 0.5 7 | } else { 8 | 1.0 9 | } 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | use assert_approx_eq::assert_approx_eq; 16 | let n = 1; 17 | let res = 1.0; 18 | assert_approx_eq!(Solution::nth_person_gets_nth_seat(n), res); 19 | let n = 2; 20 | let res = 0.5; 21 | assert_approx_eq!(Solution::nth_person_gets_nth_seat(n), res); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d12/_1256_encode_number.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn encode(num: i32) -> String { 5 | format!("{:b}", num + 1)[1..].to_string() 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | let num = 23; 12 | let res = "1000".to_string(); 13 | assert_eq!(Solution::encode(num), res); 14 | let num = 107; 15 | let res = "101100".to_string(); 16 | assert_eq!(Solution::encode(num), res); 17 | } 18 | -------------------------------------------------------------------------------- /leetcode/src/d12/_1281_subtract_the_product_and_sum_of_digits_of_an_integer.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn subtract_product_and_sum(mut n: i32) -> i32 { 5 | let mut product = 1; 6 | let mut sum = 0; 7 | while n != 0 { 8 | let d = n % 10; 9 | product *= d; 10 | sum += d; 11 | n /= 10; 12 | } 13 | product - sum 14 | } 15 | } 16 | 17 | #[test] 18 | fn test() { 19 | assert_eq!(Solution::subtract_product_and_sum(234), 15); 20 | } 21 | -------------------------------------------------------------------------------- /leetcode/src/d12/_1287_element_appearing_more_than_25_in_sorted_array.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn find_special_integer(arr: Vec) -> i32 { 5 | let n = arr.len(); 6 | let t = n / 4; 7 | for i in 0..n - t { 8 | if arr[i] == arr[i + t] { 9 | return arr[i]; 10 | } 11 | } 12 | 0 13 | } 14 | } 15 | 16 | #[test] 17 | fn test() { 18 | let arr = vec![1, 2, 2, 6, 6, 6, 6, 7, 10]; 19 | assert_eq!(Solution::find_special_integer(arr), 6); 20 | } 21 | -------------------------------------------------------------------------------- /leetcode/src/d12/_1290_convert_binary_number_in_a_linked_list_to_integer.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | use rustgym_util::*; 3 | 4 | impl Solution { 5 | fn get_decimal_value(head: ListLink) -> i32 { 6 | let mut p: &ListLink = &head; 7 | let mut res = 0; 8 | while let Some(n) = p { 9 | res *= 2; 10 | res += n.val; 11 | p = &n.next; 12 | } 13 | res 14 | } 15 | } 16 | 17 | #[test] 18 | fn test() { 19 | let head = list!(1, 0, 1); 20 | assert_eq!(Solution::get_decimal_value(head), 5); 21 | } 22 | -------------------------------------------------------------------------------- /leetcode/src/d12/_1295_find_numbers_with_even_number_of_digits.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn digits(mut n: i32) -> i32 { 5 | let mut res = 0; 6 | while n != 0 { 7 | n /= 10; 8 | res += 1; 9 | } 10 | res 11 | } 12 | fn find_numbers(nums: Vec) -> i32 { 13 | let mut res = 0; 14 | for n in nums { 15 | if Self::digits(n) % 2 == 0 { 16 | res += 1; 17 | } 18 | } 19 | res 20 | } 21 | } 22 | 23 | #[test] 24 | fn test() { 25 | assert_eq!(Solution::find_numbers(vec![12, 345, 2, 6, 7896]), 2); 26 | } 27 | -------------------------------------------------------------------------------- /leetcode/src/d12/_1299_replace_elements_with_greatest_element_on_right_side.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | use std::i32; 3 | 4 | impl Solution { 5 | fn replace_elements(mut arr: Vec) -> Vec { 6 | let mut max = -1; 7 | let n = arr.len(); 8 | for i in (0..n).rev() { 9 | let t = max; 10 | max = i32::max(arr[i], max); 11 | arr[i] = t; 12 | } 13 | arr 14 | } 15 | } 16 | 17 | #[test] 18 | fn test() { 19 | let arr = vec![17, 18, 5, 4, 6, 1]; 20 | let res = vec![18, 6, 6, 6, 1, -1]; 21 | assert_eq!(Solution::replace_elements(arr), res); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d13/_1313_decompres_run_length_encoded_list.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn decompress_rl_elist(nums: Vec) -> Vec { 5 | let mut res = vec![]; 6 | for p in nums.chunks(2) { 7 | let a = p[0] as usize; 8 | let b = p[1]; 9 | for _ in 0..a { 10 | res.push(b); 11 | } 12 | } 13 | res 14 | } 15 | } 16 | 17 | #[test] 18 | fn test() { 19 | let nums = vec![1, 2, 3, 4]; 20 | let res = vec![2, 4, 4, 4]; 21 | assert_eq!(Solution::decompress_rl_elist(nums), res); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d13/_1374_generate_a_string_with_characters_that_have_odd_counts.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn generate_the_string(n: i32) -> String { 5 | let mut s: String = "a".repeat((n - 1) as usize); 6 | s.push(if n % 2 == 0 { 'b' } else { 'a' }); 7 | s 8 | } 9 | } 10 | 11 | #[test] 12 | fn test() { 13 | let n = 4; 14 | let res = "aaab".to_string(); 15 | assert_eq!(Solution::generate_the_string(n), res); 16 | let n = 7; 17 | let res = "aaaaaaa".to_string(); 18 | assert_eq!(Solution::generate_the_string(n), res); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d14/_1413_minimum_value_to_get_positive_step_by_step_sum.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn min_start_value(nums: Vec) -> i32 { 5 | let n = nums.len(); 6 | let mut sum = 0; 7 | let mut start = 1; 8 | for i in 0..n { 9 | sum += nums[i]; 10 | if start + sum < 1 { 11 | start = start.max(1 - sum); 12 | } 13 | } 14 | start 15 | } 16 | } 17 | 18 | #[test] 19 | fn test() { 20 | let nums = vec![-3, 2, -3, 4, 2]; 21 | let res = 5; 22 | assert_eq!(Solution::min_start_value(nums), res); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d14/_1460_make_two_arrays_equal_by_reversing_sub_arrays.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn can_be_equal(mut target: Vec, mut arr: Vec) -> bool { 5 | target.sort_unstable(); 6 | arr.sort_unstable(); 7 | target == arr 8 | } 9 | } 10 | 11 | #[test] 12 | fn test() { 13 | let target = vec![1, 2, 3, 4]; 14 | let arr = vec![2, 4, 1, 3]; 15 | let res = true; 16 | assert_eq!(Solution::can_be_equal(target, arr), res); 17 | let target = vec![3, 7, 9]; 18 | let arr = vec![3, 7, 11]; 19 | let res = false; 20 | assert_eq!(Solution::can_be_equal(target, arr), res); 21 | } 22 | -------------------------------------------------------------------------------- /leetcode/src/d14/_1464_maximum_product_of_two_elements_in_an_array.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn max_product(mut nums: Vec) -> i32 { 5 | let n = nums.len(); 6 | nums.sort_unstable(); 7 | (nums[n - 1] - 1) * (nums[n - 2] - 1) 8 | } 9 | } 10 | 11 | #[test] 12 | fn test() { 13 | let nums = vec![3, 4, 5, 2]; 14 | let res = 12; 15 | assert_eq!(Solution::max_product(nums), res); 16 | let nums = vec![1, 5, 4, 5]; 17 | let res = 16; 18 | assert_eq!(Solution::max_product(nums), res); 19 | let nums = vec![3, 7]; 20 | let res = 12; 21 | assert_eq!(Solution::max_product(nums), res); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d15/_1502_can_make_arithmetic_progression_from_sequence.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn can_make_arithmetic_progression(mut arr: Vec) -> bool { 5 | arr.sort_unstable(); 6 | let diff: Vec = arr.windows(2).map(|v| v[1] - v[0]).collect(); 7 | diff.iter().min() == diff.iter().max() 8 | } 9 | } 10 | 11 | #[test] 12 | fn test() { 13 | let arr = vec![3, 5, 1]; 14 | let res = true; 15 | assert_eq!(Solution::can_make_arithmetic_progression(arr), res); 16 | let arr = vec![1, 2, 4]; 17 | let res = false; 18 | assert_eq!(Solution::can_make_arithmetic_progression(arr), res); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d15/_1523_cound_odd_numbers_in_interval_range.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn count_odds(low: i32, high: i32) -> i32 { 5 | let l = low / 2 * 2; 6 | let r = (high + 1) / 2 * 2; 7 | (r - l) / 2 8 | } 9 | } 10 | 11 | #[test] 12 | fn test() { 13 | let low = 3; 14 | let high = 7; 15 | let res = 3; 16 | assert_eq!(Solution::count_odds(low, high), res); 17 | let low = 8; 18 | let high = 10; 19 | let res = 1; 20 | assert_eq!(Solution::count_odds(low, high), res); 21 | } 22 | -------------------------------------------------------------------------------- /leetcode/src/d15/_1550_three_consecutive_odds.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn three_consecutive_odds(arr: Vec) -> bool { 5 | arr.windows(3) 6 | .any(|w| w[0] % 2 == 1 && w[1] % 2 == 1 && w[2] % 2 == 1) 7 | } 8 | } 9 | 10 | #[test] 11 | fn test() { 12 | let arr = vec![2, 6, 4, 1]; 13 | let res = false; 14 | assert_eq!(Solution::three_consecutive_odds(arr), res); 15 | let arr = vec![1, 2, 34, 3, 4, 5, 7, 23, 12]; 16 | let res = true; 17 | assert_eq!(Solution::three_consecutive_odds(arr), res); 18 | } 19 | -------------------------------------------------------------------------------- /leetcode/src/d15/_1551_minimum_operations_to_make_array_equalrs.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn min_operations(n: i32) -> i32 { 5 | let mut res = 0; 6 | let mut i = 1; 7 | while i < n { 8 | res += n - i; 9 | i += 2; 10 | } 11 | res 12 | } 13 | } 14 | 15 | #[test] 16 | fn test() { 17 | let n = 3; 18 | let res = 2; 19 | assert_eq!(Solution::min_operations(n), res); 20 | let n = 6; 21 | let res = 9; 22 | assert_eq!(Solution::min_operations(n), res); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d16/_1672_richest_customer_wealth.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn maximum_wealth(accounts: Vec>) -> i32 { 5 | accounts 6 | .into_iter() 7 | .map(|v| v.into_iter().sum()) 8 | .max() 9 | .unwrap() 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /leetcode/src/d16/_1688_count_of_matches_in_tournament.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn number_of_matches(mut n: i32) -> i32 { 5 | let mut res = 0; 6 | while n > 1 { 7 | if n % 2 == 1 { 8 | res += 1; 9 | } 10 | n /= 2; 11 | res += n; 12 | } 13 | res 14 | } 15 | } 16 | 17 | #[test] 18 | fn test() { 19 | let n = 7; 20 | let res = 6; 21 | assert_eq!(Solution::number_of_matches(n), res); 22 | let n = 14; 23 | let res = 13; 24 | assert_eq!(Solution::number_of_matches(n), res); 25 | } 26 | -------------------------------------------------------------------------------- /leetcode/src/d16/_1689_partitioning_into_minimum_number_of_deci_binary_numbers.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn min_partitions(n: String) -> i32 { 5 | let mut res = 0; 6 | for b in n.bytes() { 7 | res = res.max(b - b'0'); 8 | } 9 | res as i32 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | let n = "32".to_string(); 16 | let res = 3; 17 | assert_eq!(Solution::min_partitions(n), res); 18 | } 19 | -------------------------------------------------------------------------------- /leetcode/src/d17/_1716_calculate_money_in_leetcode_bank.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn total_money(n: i32) -> i32 { 5 | let mut res = 0; 6 | for i in 0..n { 7 | res += (i % 7) + (i / 7) + 1; 8 | } 9 | res 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | let n = 4; 16 | let res = 10; 17 | assert_eq!(Solution::total_money(n), res); 18 | let n = 10; 19 | let res = 37; 20 | assert_eq!(Solution::total_money(n), res); 21 | let n = 20; 22 | let res = 96; 23 | assert_eq!(Solution::total_money(n), res); 24 | } 25 | -------------------------------------------------------------------------------- /leetcode/src/d17/_1732_find_the_highest_altitude.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn largest_altitude(gain: Vec) -> i32 { 5 | let mut res = 0; 6 | let mut height = 0; 7 | for x in gain { 8 | height += x; 9 | res = res.max(height); 10 | } 11 | res 12 | } 13 | } 14 | 15 | #[test] 16 | fn test() { 17 | let gain = vec![-5, 1, 5, 0, -7]; 18 | let res = 1; 19 | assert_eq!(Solution::largest_altitude(gain), res); 20 | let gain = vec![-4, -3, -2, -1, 4, 3, 2]; 21 | let res = 0; 22 | assert_eq!(Solution::largest_altitude(gain), res); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d17/_1760_minimum_limit_of_balls_in_a_bag.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/leetcode/src/d17/_1760_minimum_limit_of_balls_in_a_bag.rs -------------------------------------------------------------------------------- /leetcode/src/d18/_1810_minimum_path_cost_in_a_hidden_grid.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/leetcode/src/d18/_1810_minimum_path_cost_in_a_hidden_grid.rs -------------------------------------------------------------------------------- /leetcode/src/d18/_1816_truncate_sentence.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn truncate_sentence(s: String, k: i32) -> String { 5 | let words: Vec<&str> = s.split_whitespace().take(k as usize).collect(); 6 | words.join(" ") 7 | } 8 | } 9 | 10 | #[test] 11 | fn test() { 12 | let s = "Hello how are you Contestant".to_string(); 13 | let k = 4; 14 | let res = "Hello how are you".to_string(); 15 | assert_eq!(Solution::truncate_sentence(s, k), res); 16 | } 17 | -------------------------------------------------------------------------------- /leetcode/src/d18/_1822_sign_of_the_product_of_an_array.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn array_sign(nums: Vec) -> i32 { 5 | nums.into_iter().map(|x| x.signum()).product() 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | let nums = vec![-1, -2, -3, -4, 3, 2, 1]; 12 | let res = 1; 13 | assert_eq!(Solution::array_sign(nums), res); 14 | let nums = vec![1, 5, 0, 2, -3]; 15 | let res = 0; 16 | assert_eq!(Solution::array_sign(nums), res); 17 | let nums = vec![-1, 1, -1, 1, -1]; 18 | let res = -1; 19 | assert_eq!(Solution::array_sign(nums), res); 20 | } 21 | -------------------------------------------------------------------------------- /leetcode/src/d18/_1837_sum_of_digits_in_base_k.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn sum_base(mut n: i32, k: i32) -> i32 { 5 | let mut res = 0; 6 | while n > 0 { 7 | res += n % k; 8 | n /= k; 9 | } 10 | res 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | let n = 34; 17 | let k = 6; 18 | let res = 9; 19 | assert_eq!(Solution::sum_base(n, k), res); 20 | let n = 10; 21 | let k = 10; 22 | let res = 1; 23 | assert_eq!(Solution::sum_base(n, k), res); 24 | } 25 | -------------------------------------------------------------------------------- /leetcode/src/d18/_1863_sum_of_all_subset_xor_totals.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn subset_xor_sum(nums: Vec) -> i32 { 5 | let mut mask = 0; 6 | let n = nums.len(); 7 | for i in 0..n { 8 | mask |= nums[i]; 9 | } 10 | mask << (n - 1) 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | let nums = vec![1, 3]; 17 | let res = 6; 18 | assert_eq!(Solution::subset_xor_sum(nums), res); 19 | let nums = vec![5, 1, 6]; 20 | let res = 28; 21 | assert_eq!(Solution::subset_xor_sum(nums), res); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d19/_1913_maximum_product_difference_between_two_pairs.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn max_product_difference(mut nums: Vec) -> i32 { 5 | let n = nums.len(); 6 | nums.sort_unstable(); 7 | nums[n - 1] * nums[n - 2] - nums[0] * nums[1] 8 | } 9 | } 10 | 11 | #[test] 12 | fn test() { 13 | let nums = vec![5, 6, 2, 7, 4]; 14 | let res = 34; 15 | assert_eq!(Solution::max_product_difference(nums), res); 16 | let nums = vec![4, 2, 5, 9, 7, 4, 8]; 17 | let res = 64; 18 | assert_eq!(Solution::max_product_difference(nums), res); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d19/_1920_build_array_from_permutation.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn build_array(nums: Vec) -> Vec { 5 | let n = nums.len(); 6 | let mut res = vec![0; n]; 7 | for i in 0..n { 8 | res[i] = nums[nums[i] as usize]; 9 | } 10 | res 11 | } 12 | } 13 | #[test] 14 | fn test() { 15 | let nums = vec![0, 2, 1, 5, 3, 4]; 16 | let res = vec![0, 1, 2, 4, 5, 3]; 17 | assert_eq!(Solution::build_array(nums), res); 18 | let nums = vec![5, 0, 1, 2, 3, 4]; 19 | let res = vec![4, 5, 0, 1, 2, 3]; 20 | assert_eq!(Solution::build_array(nums), res); 21 | } 22 | -------------------------------------------------------------------------------- /leetcode/src/d19/_1929_concatenation_of_array.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn get_concatenation(nums: Vec) -> Vec { 5 | [nums.clone(), nums].concat() 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | let nums = vec![1, 2, 1]; 12 | let res = vec![1, 2, 1, 1, 2, 1]; 13 | assert_eq!(Solution::get_concatenation(nums), res); 14 | let nums = vec![1, 3, 2, 1]; 15 | let res = vec![1, 3, 2, 1, 1, 3, 2, 1]; 16 | assert_eq!(Solution::get_concatenation(nums), res); 17 | } 18 | -------------------------------------------------------------------------------- /leetcode/src/d19/_1952_three_divisors.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn is_three(n: i32) -> bool { 5 | let mut count = 2; 6 | for i in 2..n { 7 | if n % i == 0 { 8 | count += 1; 9 | } 10 | } 11 | count == 3 12 | } 13 | } 14 | 15 | #[test] 16 | fn test() { 17 | let n = 2; 18 | let res = false; 19 | assert_eq!(Solution::is_three(n), res); 20 | let n = 4; 21 | let res = true; 22 | assert_eq!(Solution::is_three(n), res); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d2/_201_bitwise_and_of_numbers_range.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn range_bitwise_and(mut m: i32, mut n: i32) -> i32 { 5 | let mut shift = 0; 6 | while m != n { 7 | m >>= 1; 8 | n >>= 1; 9 | shift += 1; 10 | } 11 | n << shift 12 | } 13 | } 14 | 15 | #[test] 16 | fn test() { 17 | let m = 5; 18 | let n = 7; 19 | let res = 4; 20 | assert_eq!(Solution::range_bitwise_and(m, n), res); 21 | let m = 0; 22 | let n = 1; 23 | let res = 0; 24 | assert_eq!(Solution::range_bitwise_and(m, n), res); 25 | } 26 | -------------------------------------------------------------------------------- /leetcode/src/d2/_231_power_of_two.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn is_power_of_two(n: i32) -> bool { 5 | if n <= 0 { 6 | return false; 7 | } 8 | n & (n - 1) == 0 9 | } 10 | } 11 | 12 | #[test] 13 | fn test() { 14 | assert_eq!(Solution::is_power_of_two(1), true); 15 | assert_eq!(Solution::is_power_of_two(16), true); 16 | assert_eq!(Solution::is_power_of_two(218), false); 17 | } 18 | -------------------------------------------------------------------------------- /leetcode/src/d2/_233_number_of_digit_one.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn count_digit_one(n: i32) -> i32 { 5 | let mut m = 1i64; 6 | let mut res = 0i64; 7 | let n = n as i64; 8 | while m <= n { 9 | let d = 10 * m; 10 | res += n / d * m + m.min(0.max(n % d - m + 1)); 11 | m *= 10; 12 | } 13 | res as i32 14 | } 15 | } 16 | 17 | #[test] 18 | fn test() { 19 | let n = 13; 20 | let res = 6; 21 | assert_eq!(Solution::count_digit_one(n), res); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d2/_242_valid_anagram.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn is_anagram(s: String, t: String) -> bool { 5 | let mut s: Vec = s.chars().collect(); 6 | let mut t: Vec = t.chars().collect(); 7 | s.sort_unstable(); 8 | t.sort_unstable(); 9 | s == t 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | assert_eq!( 16 | Solution::is_anagram("anagram".to_string(), "nagaram".to_string()), 17 | true 18 | ); 19 | assert_eq!( 20 | Solution::is_anagram("rat".to_string(), "car".to_string()), 21 | false 22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d2/_258_add_digits.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn add_digits(mut num: i32) -> i32 { 5 | while num > 9 { 6 | num = Self::add_digits_once(num); 7 | } 8 | num 9 | } 10 | fn add_digits_once(mut num: i32) -> i32 { 11 | let mut res = 0; 12 | while num > 0 { 13 | res += num % 10; 14 | num /= 10; 15 | } 16 | res 17 | } 18 | } 19 | 20 | #[test] 21 | fn test() { 22 | assert_eq!(Solution::add_digits(38), 2); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d2/_260_single_number_3.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn single_number(nums: Vec) -> Vec { 5 | let mut bitmask = 0; 6 | for &num in &nums { 7 | bitmask ^= num; 8 | } 9 | let diff = bitmask & (-bitmask); 10 | let mut x = 0; 11 | for &num in &nums { 12 | if diff & num != 0 { 13 | x ^= num; 14 | } 15 | } 16 | vec![x, bitmask ^ x] 17 | } 18 | } 19 | 20 | #[test] 21 | fn test() { 22 | let nums = vec![1, 2, 1, 3, 2, 5]; 23 | let res = vec![3, 5]; 24 | assert_eq!(Solution::single_number(nums), res); 25 | } 26 | -------------------------------------------------------------------------------- /leetcode/src/d2/_263_ugly_number.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn is_ugly(mut num: i32) -> bool { 5 | if num < 1 { 6 | return false; 7 | } 8 | while num % 2 == 0 { 9 | num /= 2; 10 | } 11 | while num % 3 == 0 { 12 | num /= 3; 13 | } 14 | while num % 5 == 0 { 15 | num /= 5; 16 | } 17 | num == 1 18 | } 19 | } 20 | 21 | #[test] 22 | fn test() { 23 | assert_eq!(Solution::is_ugly(6), true); 24 | assert_eq!(Solution::is_ugly(8), true); 25 | assert_eq!(Solution::is_ugly(14), false); 26 | } 27 | -------------------------------------------------------------------------------- /leetcode/src/d2/_268_missing_number.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn missing_number(nums: Vec) -> i32 { 5 | let mut xor: i32 = 0; 6 | let n = nums.len(); 7 | for n in 0..=n { 8 | xor ^= n as i32; 9 | } 10 | for n in nums { 11 | xor ^= n; 12 | } 13 | xor 14 | } 15 | } 16 | 17 | #[test] 18 | fn test() { 19 | let nums = vec![9, 6, 4, 2, 3, 5, 7, 0, 1]; 20 | assert_eq!(Solution::missing_number(nums), 8); 21 | } 22 | -------------------------------------------------------------------------------- /leetcode/src/d2/_283_move_zeros.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn move_zeroes(nums: &mut Vec) { 5 | let mut j = 0; 6 | for i in 0..nums.len() { 7 | let x = nums[i]; 8 | if x != 0 { 9 | nums[i] = 0; 10 | nums[j] = x; 11 | j += 1; 12 | } 13 | } 14 | } 15 | } 16 | 17 | #[test] 18 | fn test() { 19 | let mut nums = vec![0, 1, 0, 3, 12]; 20 | Solution::move_zeroes(&mut nums); 21 | assert_eq!(nums, vec![1, 3, 12, 0, 0]); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d2/_292_nim_game.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn can_win_nim(n: i32) -> bool { 5 | n % 4 != 0 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | assert_eq!(Solution::can_win_nim(4), false); 12 | } 13 | -------------------------------------------------------------------------------- /leetcode/src/d2/_293_flip_game.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn generate_possible_next_moves(s: String) -> Vec { 5 | let mut res: Vec = vec![]; 6 | let n = s.len(); 7 | for i in 1..n { 8 | if &s[i - 1..=i] == "++" { 9 | res.push(format!("{}{}{}", &s[0..i - 1], "--", &s[i + 1..])); 10 | } 11 | } 12 | res 13 | } 14 | } 15 | 16 | #[test] 17 | fn test() { 18 | let s = "++++".to_string(); 19 | let res: Vec = vec_string!["--++", "+--+", "++--"]; 20 | assert_eq!(Solution::generate_possible_next_moves(s), res); 21 | } 22 | -------------------------------------------------------------------------------- /leetcode/src/d21/_2119_a_number_after_a_double_reversal.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn is_same_after_reversals(num: i32) -> bool { 5 | num == 0 || num % 10 != 0 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | let num = 526; 12 | let res = true; 13 | assert_eq!(Solution::is_same_after_reversals(num), res); 14 | let num = 1800; 15 | let res = false; 16 | assert_eq!(Solution::is_same_after_reversals(num), res); 17 | let num = 0; 18 | let res = true; 19 | assert_eq!(Solution::is_same_after_reversals(num), res); 20 | } 21 | -------------------------------------------------------------------------------- /leetcode/src/d21/mod.rs: -------------------------------------------------------------------------------- 1 | mod _2103_rings_and_rods; 2 | // 3 | mod _2108_find_first_palindromic_string_in_the_array; 4 | // 5 | mod _2114_maximum_number_of_words_found_in_sentences; 6 | // 7 | mod _2119_a_number_after_a_double_reversal; 8 | // 9 | mod _2124_check_if_all_a_s_appears_before_all_b_s; 10 | // 11 | mod _2129_capitalize_the_title; 12 | // 13 | mod _2133_check_if_every_row_and_column_contains_all_numbers; 14 | // 15 | mod _2138_divide_a_string_into_groups_of_size_k; 16 | // 17 | mod _2144_minimum_cost_of_buying_candies_with_discount; 18 | // 19 | mod _2148_count_elements_with_strictly_smaller_and_greater_elements; 20 | -------------------------------------------------------------------------------- /leetcode/src/d3/_300_longest_increasing_subsequence.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn length_of_lis(nums: Vec) -> i32 { 5 | let mut dp: Vec = vec![]; 6 | for x in nums { 7 | if let Err(i) = dp.binary_search(&x) { 8 | if i == dp.len() { 9 | dp.push(x) 10 | } else { 11 | dp[i] = x; 12 | } 13 | } 14 | } 15 | dp.len() as i32 16 | } 17 | } 18 | 19 | #[test] 20 | fn test() { 21 | let nums = vec![10, 9, 2, 5, 3, 7, 101, 18]; 22 | let res = 4; 23 | assert_eq!(Solution::length_of_lis(nums), res); 24 | } 25 | -------------------------------------------------------------------------------- /leetcode/src/d3/_319_bulb_switcher.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn bulb_switch(n: i32) -> i32 { 5 | (n as f64).sqrt() as i32 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | let n = 3; 12 | let res = 1; 13 | assert_eq!(Solution::bulb_switch(n), res); 14 | } 15 | -------------------------------------------------------------------------------- /leetcode/src/d3/_326_power_of_three.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn is_power_of_three(n: i32) -> bool { 5 | n > 0 && 1_162_261_467 % n == 0 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | assert_eq!(Solution::is_power_of_three(27), true); 12 | assert_eq!(Solution::is_power_of_three(0), false); 13 | assert_eq!(Solution::is_power_of_three(9), true); 14 | assert_eq!(Solution::is_power_of_three(45), false); 15 | } 16 | -------------------------------------------------------------------------------- /leetcode/src/d3/_338_counting_bits.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn count_bits(num: i32) -> Vec { 5 | let n = num as usize; 6 | let mut res = vec![]; 7 | for i in 0..=n { 8 | res.push(i.count_ones() as i32); 9 | } 10 | res 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | let num = 2; 17 | let res = vec![0, 1, 1]; 18 | assert_eq!(Solution::count_bits(num), res); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d3/_342_power_of_four.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | use std::i32; 4 | 5 | impl Solution { 6 | fn is_power_of_four(mut n: i32) -> bool { 7 | while n != 0 && n % 4 == 0 { 8 | n /= 4; 9 | } 10 | n == 1 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | assert_eq!(Solution::is_power_of_four(16), true); 17 | } 18 | -------------------------------------------------------------------------------- /leetcode/src/d3/_344_reverse_string.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn reverse_string(s: &mut Vec) { 5 | s.reverse(); 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | let mut input: Vec = vec![]; 12 | let output: Vec = vec![]; 13 | Solution::reverse_string(&mut input); 14 | assert_eq!(input, output); 15 | let mut input: Vec = vec!['h', 'e', 'l', 'l', 'o']; 16 | let output: Vec = vec!['o', 'l', 'l', 'e', 'h']; 17 | Solution::reverse_string(&mut input); 18 | assert_eq!(input, output); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d3/_349_intersection_of_two_arrays.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | use std::collections::HashSet; 4 | 5 | impl Solution { 6 | fn intersection(nums1: Vec, nums2: Vec) -> Vec { 7 | let h1: HashSet = nums1.into_iter().collect(); 8 | let h2: HashSet = nums2.into_iter().collect(); 9 | let bitand = &h1 & &h2; 10 | bitand.into_iter().collect() 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | let nums1 = vec![1, 2, 2, 1]; 17 | let nums2 = vec![2, 2]; 18 | assert_eq!(Solution::intersection(nums1, nums2), vec![2]); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d3/_367_valid_perfect_square.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn is_perfect_square(num: i32) -> bool { 5 | let mut r: i64 = num as i64; 6 | let x: i64 = num as i64; 7 | while r * r > x { 8 | r = (r + x / r) / 2; 9 | } 10 | r * r == x 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | assert_eq!(Solution::is_perfect_square(16), true); 17 | assert_eq!(Solution::is_perfect_square(14), false); 18 | } 19 | -------------------------------------------------------------------------------- /leetcode/src/d3/_371_sum_of_two_integers.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn get_sum(a: i32, b: i32) -> i32 { 5 | if b == 0 { 6 | a 7 | } else { 8 | Self::get_sum(a ^ b, (a & b) << 1) 9 | } 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | assert_eq!(Solution::get_sum(1, 2), 3); 16 | assert_eq!(Solution::get_sum(-2, 3), 1); 17 | } 18 | -------------------------------------------------------------------------------- /leetcode/src/d3/_390_elimination_game.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn last_remaining(n: i32) -> i32 { 5 | if n == 1 { 6 | 1 7 | } else { 8 | 2 * (1 + n / 2 - Self::last_remaining(n / 2)) 9 | } 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | let n = 9; 16 | let res = 6; 17 | assert_eq!(Solution::last_remaining(n), res); 18 | } 19 | -------------------------------------------------------------------------------- /leetcode/src/d4/_405_convert_a_number_to_hexadecimal.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | #[allow(clippy::wrong_self_convention)] 4 | impl Solution { 5 | fn to_hex(num: i32) -> String { 6 | format!("{:x}", num) 7 | } 8 | } 9 | 10 | #[test] 11 | fn test() { 12 | let num = -1; 13 | let res = "ffffffff"; 14 | assert_eq!(Solution::to_hex(num), res); 15 | } 16 | -------------------------------------------------------------------------------- /leetcode/src/d4/_434_number_of_segments_in_a_string.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn count_segments(s: String) -> i32 { 5 | s.split_whitespace().count() as i32 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | let s = "Hello, my name is John".to_string(); 12 | assert_eq!(Solution::count_segments(s), 5); 13 | } 14 | -------------------------------------------------------------------------------- /leetcode/src/d4/_441_arranging_coins.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn arrange_coins(n: i32) -> i32 { 5 | (((2 * n as i64) as f64 + 0.25).sqrt() - 0.5).floor() as i32 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | assert_eq!(Solution::arrange_coins(5), 2); 12 | assert_eq!(Solution::arrange_coins(8), 3); 13 | assert_eq!(Solution::arrange_coins(1_804_289_383), 60070); 14 | } 15 | -------------------------------------------------------------------------------- /leetcode/src/d4/_453_minimum_moves_to_equal_array_elements.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn min_moves(nums: Vec) -> i32 { 5 | let mut min = nums[0]; 6 | let mut sum = 0; 7 | for &x in &nums { 8 | min = i32::min(x, min); 9 | } 10 | for &x in &nums { 11 | sum += x - min; 12 | } 13 | sum 14 | } 15 | } 16 | 17 | #[test] 18 | fn test() { 19 | let nums = vec![1, 2, 3]; 20 | assert_eq!(Solution::min_moves(nums), 3); 21 | } 22 | -------------------------------------------------------------------------------- /leetcode/src/d4/_458_poor_pigs.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn poor_pigs(buckets: i32, minutes_to_die: i32, minutes_to_test: i32) -> i32 { 5 | let mut pigs = 0; 6 | let t = minutes_to_test / minutes_to_die + 1; 7 | while t.pow(pigs) < buckets { 8 | pigs += 1; 9 | } 10 | pigs as i32 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | let buckets = 1000; 17 | let minutes_to_test = 60; 18 | let minutes_to_die = 15; 19 | let res = 5; 20 | assert_eq!( 21 | Solution::poor_pigs(buckets, minutes_to_die, minutes_to_test), 22 | res 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /leetcode/src/d4/_461_hamming_distance.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn hamming_distance(x: i32, y: i32) -> i32 { 5 | let mut z = x ^ y; 6 | let mut sum = 0; 7 | for _ in 0..32 { 8 | sum += z & 1; 9 | z >>= 1; 10 | } 11 | sum 12 | } 13 | } 14 | 15 | #[test] 16 | fn test() { 17 | assert_eq!(Solution::hamming_distance(1, 4), 2); 18 | } 19 | -------------------------------------------------------------------------------- /leetcode/src/d4/_462_minimum_moves_to_equal_array_elements_2.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn min_moves2(mut nums: Vec) -> i32 { 5 | nums.sort_unstable(); 6 | let n = nums.len(); 7 | let median = nums[n / 2]; 8 | nums.into_iter().map(|x| (x - median).abs()).sum() 9 | } 10 | } 11 | 12 | #[test] 13 | fn test() { 14 | let nums = vec![1, 2, 3]; 15 | let res = 2; 16 | assert_eq!(Solution::min_moves2(nums), res); 17 | } 18 | -------------------------------------------------------------------------------- /leetcode/src/d4/_470_implement_rand10_using_rand7.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | use rand::distributions::Uniform; 4 | use rand::thread_rng; 5 | use rand::Rng; 6 | 7 | impl Solution { 8 | fn rand10() -> i32 { 9 | let distribution: Uniform = Uniform::new(0, 10); 10 | let mut rng = thread_rng(); 11 | rng.sample(distribution) + 1 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /leetcode/src/d4/_476_number_complement.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn find_complement(num: i32) -> i32 { 5 | let mut mask = !0; 6 | while mask & num != 0 { 7 | mask <<= 1; 8 | } 9 | !mask & !num 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | assert_eq!(Solution::find_complement(5), 2); 16 | assert_eq!(Solution::find_complement(1), 0); 17 | } 18 | -------------------------------------------------------------------------------- /leetcode/src/d4/_485_max_consecutive_ones.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn find_max_consecutive_ones(nums: Vec) -> i32 { 5 | let mut max = 0; 6 | let mut count = 0; 7 | for x in nums { 8 | if x == 1 { 9 | count += 1; 10 | max = i32::max(count, max); 11 | } else { 12 | count = 0; 13 | } 14 | } 15 | max 16 | } 17 | } 18 | 19 | #[test] 20 | fn test() { 21 | let nums = vec![1, 1, 0, 1, 1, 1]; 22 | assert_eq!(Solution::find_max_consecutive_ones(nums), 3); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d4/_492_construct_the_rectangle.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn construct_rectangle(area: i32) -> Vec { 5 | let mut max = (area as f64).sqrt().floor() as i32; 6 | while area % max != 0 { 7 | max -= 1; 8 | } 9 | vec![area / max, max] 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | assert_eq!(Solution::construct_rectangle(4), vec![2, 2]); 16 | } 17 | -------------------------------------------------------------------------------- /leetcode/src/d5/_507_perfect_number.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn check_perfect_number(num: i32) -> bool { 5 | if num == 1 { 6 | return false; 7 | } 8 | let mut i = 2; 9 | let mut sum = 1; 10 | while i * i <= num { 11 | if num % i == 0 { 12 | sum += i; 13 | sum += num / i; 14 | } 15 | i += 1; 16 | } 17 | sum == num 18 | } 19 | } 20 | 21 | #[test] 22 | fn test() { 23 | assert_eq!(Solution::check_perfect_number(28), true); 24 | } 25 | -------------------------------------------------------------------------------- /leetcode/src/d5/_509_fibonacci_number.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn fib(n: i32) -> i32 { 5 | let mut a: Vec = vec![0; 31]; 6 | a[1] = 1; 7 | for i in 2..=30 { 8 | a[i] = a[i - 1] + a[i - 2]; 9 | } 10 | a[n as usize] 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | assert_eq!(Solution::fib(2), 1); 17 | assert_eq!(Solution::fib(3), 2); 18 | assert_eq!(Solution::fib(4), 3); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d5/_521_longest_uncommon_subsequence_1.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn find_lu_slength(a: String, b: String) -> i32 { 5 | if a == b { 6 | -1 7 | } else { 8 | a.len().max(b.len()) as i32 9 | } 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | let a = "aba".to_string(); 16 | let b = "cdc".to_string(); 17 | assert_eq!(Solution::find_lu_slength(a, b), 3); 18 | } 19 | -------------------------------------------------------------------------------- /leetcode/src/d5/_528_random_pick_with_weight.rs: -------------------------------------------------------------------------------- 1 | use rand::distributions::WeightedIndex; 2 | use rand::prelude::*; 3 | 4 | struct Solution { 5 | dist: WeightedIndex, 6 | rng: ThreadRng, 7 | } 8 | 9 | impl Solution { 10 | fn new(w: Vec) -> Self { 11 | let rng = thread_rng(); 12 | let dist = WeightedIndex::new(w).unwrap(); 13 | Solution { dist, rng } 14 | } 15 | 16 | fn pick_index(&mut self) -> i32 { 17 | self.rng.sample(&self.dist) as i32 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d5/_535_encode_and_decode_tiny_url.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | struct Codec {} 3 | 4 | impl Codec { 5 | fn new() -> Self { 6 | Codec {} 7 | } 8 | 9 | fn encode(&self, long: String) -> String { 10 | long 11 | } 12 | 13 | fn decode(&self, short: String) -> String { 14 | short 15 | } 16 | } 17 | 18 | #[test] 19 | fn test() { 20 | let obj = Codec::new(); 21 | let long = "design-tinyurl"; 22 | assert_eq!(obj.decode(obj.encode(long.to_string())), long.to_string()); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d5/_551_student_attendance_record_1.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn check_record(s: String) -> bool { 5 | let s: Vec = s.chars().collect(); 6 | if s.iter().filter(|&c| c == &'A').count() > 1 { 7 | return false; 8 | } 9 | if s.windows(3).filter(|&w| w == ['L', 'L', 'L']).count() > 0 { 10 | return false; 11 | } 12 | true 13 | } 14 | } 15 | 16 | #[test] 17 | fn test() { 18 | let s = "PPALLP".to_string(); 19 | assert_eq!(Solution::check_record(s), true); 20 | let s = "PPALLLP".to_string(); 21 | assert_eq!(Solution::check_record(s), false); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d5/_557_reverse_words_in_a_string_3.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn reverse_words(s: String) -> String { 5 | let words: Vec = s 6 | .split_whitespace() 7 | .map(|s| s.chars().rev().collect()) 8 | .collect(); 9 | let res: String = words.join(" "); 10 | res 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | let s = "Let's take LeetCode contest".to_string(); 17 | let r = "s'teL ekat edoCteeL tsetnoc".to_string(); 18 | assert_eq!(Solution::reverse_words(s), r); 19 | } 20 | -------------------------------------------------------------------------------- /leetcode/src/d5/_561_array_partition_1.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn array_pair_sum(mut nums: Vec) -> i32 { 5 | nums.sort_unstable(); 6 | nums.chunks(2).fold(0, |sum, pair| sum + pair[0]) 7 | } 8 | } 9 | 10 | #[test] 11 | fn test() { 12 | let nums = vec![1, 4, 3, 2]; 13 | assert_eq!(Solution::array_pair_sum(nums), 4); 14 | } 15 | -------------------------------------------------------------------------------- /leetcode/src/d5/_575_distribute_candies.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | use std::collections::HashSet; 4 | 5 | impl Solution { 6 | fn distribute_candies(candies: Vec) -> i32 { 7 | let n = candies.len(); 8 | let mut hs: HashSet = HashSet::new(); 9 | for val in candies { 10 | hs.insert(val); 11 | } 12 | usize::min(n / 2, hs.len()) as i32 13 | } 14 | } 15 | 16 | #[test] 17 | fn test() { 18 | let candies = vec![1, 1, 2, 2, 3, 3]; 19 | assert_eq!(Solution::distribute_candies(candies), 3); 20 | let candies = vec![1, 1, 2, 3]; 21 | assert_eq!(Solution::distribute_candies(candies), 2); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d5/_598_range_addition_2.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn max_count(mut m: i32, mut n: i32, ops: Vec>) -> i32 { 5 | for op in ops { 6 | m = i32::min(op[0], m); 7 | n = i32::min(op[1], n); 8 | } 9 | m * n 10 | } 11 | } 12 | 13 | #[test] 14 | fn test() { 15 | let m = 3; 16 | let n = 3; 17 | let ops: Vec> = vec_vec_i32![[2, 2], [3, 3]]; 18 | let res = 4; 19 | assert_eq!(Solution::max_count(m, n, ops), res); 20 | } 21 | -------------------------------------------------------------------------------- /leetcode/src/d6/_628_maximum_product_of_three_numbers.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn maximum_product(mut nums: Vec) -> i32 { 5 | nums.sort_unstable(); 6 | let n = nums.len(); 7 | i32::max( 8 | nums[0] * nums[1] * nums[n - 1], 9 | nums[n - 1] * nums[n - 2] * nums[n - 3], 10 | ) 11 | } 12 | } 13 | 14 | #[test] 15 | fn test() { 16 | let nums = vec![1, 2, 3]; 17 | assert_eq!(Solution::maximum_product(nums), 6); 18 | let nums = vec![1, 2, 3, 4]; 19 | assert_eq!(Solution::maximum_product(nums), 24); 20 | } 21 | -------------------------------------------------------------------------------- /leetcode/src/d6/_634_find_the_derangement_of_an_array.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn find_derangement(n: i32) -> i32 { 5 | let n = n as usize; 6 | let mut dp = vec![0; n + 1]; 7 | dp[0] = 1; 8 | dp[1] = 0; 9 | for i in 2..=n { 10 | dp[i] = (i - 1) * (dp[i - 1] + dp[i - 2]) % 1_000_000_007; 11 | } 12 | dp[n] as i32 13 | } 14 | } 15 | 16 | #[test] 17 | fn test() { 18 | let n = 3; 19 | let res = 2; 20 | assert_eq!(Solution::find_derangement(n), res); 21 | } 22 | -------------------------------------------------------------------------------- /leetcode/src/d6/_650_2_keys_keyboard.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn min_steps(n: i32) -> i32 { 5 | let n = n as usize; 6 | let mut dp = vec![0; n + 1]; 7 | for i in 2..=n { 8 | dp[i] = i; 9 | for j in (2..i).rev() { 10 | if i % j == 0 { 11 | dp[i] = dp[j] + i / j; 12 | break; 13 | } 14 | } 15 | } 16 | dp[n] as i32 17 | } 18 | } 19 | 20 | #[test] 21 | fn test() { 22 | let n = 3; 23 | let res = 3; 24 | assert_eq!(Solution::min_steps(n), res); 25 | } 26 | -------------------------------------------------------------------------------- /leetcode/src/d6/_657_robot_return_to_origin.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn judge_circle(moves: String) -> bool { 5 | let mut x = 0; 6 | let mut y = 0; 7 | for c in moves.chars() { 8 | match c { 9 | 'U' => y += 1, 10 | 'D' => y -= 1, 11 | 'L' => x -= 1, 12 | 'R' => x += 1, 13 | _ => (), 14 | } 15 | } 16 | x == 0 && y == 0 17 | } 18 | } 19 | 20 | #[test] 21 | fn test() { 22 | assert_eq!(Solution::judge_circle("UD".to_string()), true); 23 | assert_eq!(Solution::judge_circle("LL".to_string()), false); 24 | } 25 | -------------------------------------------------------------------------------- /leetcode/src/d6/_660_remove_9.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn new_integer(mut n: i32) -> i32 { 5 | let mut res = 0; 6 | let mut base = 1; 7 | while n > 0 { 8 | res += n % 9 * base; 9 | n /= 9; 10 | base *= 10; 11 | } 12 | res 13 | } 14 | } 15 | 16 | #[test] 17 | fn test() { 18 | let n = 9; 19 | let res = 10; 20 | assert_eq!(Solution::new_integer(n), res); 21 | } 22 | -------------------------------------------------------------------------------- /leetcode/src/d6/_693_binary_number_with_alternating_bits.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn has_alternating_bits(n: i32) -> bool { 5 | let x = (n >> 1) ^ n; 6 | (x + 1) & x == 0 7 | } 8 | } 9 | 10 | #[test] 11 | fn test() { 12 | assert_eq!(Solution::has_alternating_bits(5), true); 13 | assert_eq!(Solution::has_alternating_bits(7), false); 14 | assert_eq!(Solution::has_alternating_bits(11), false); 15 | assert_eq!(Solution::has_alternating_bits(1), true); 16 | } 17 | -------------------------------------------------------------------------------- /leetcode/src/d7/_706_design_hash_map.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | struct MyHashMap { 3 | v: Vec, 4 | } 5 | 6 | const LIMIT: usize = 1_000_000; 7 | 8 | impl MyHashMap { 9 | fn new() -> Self { 10 | MyHashMap { 11 | v: vec![-1; LIMIT + 1], 12 | } 13 | } 14 | 15 | fn put(&mut self, key: i32, value: i32) { 16 | self.v[key as usize] = value; 17 | } 18 | 19 | fn get(&self, key: i32) -> i32 { 20 | self.v[key as usize] 21 | } 22 | 23 | fn remove(&mut self, key: i32) { 24 | self.v[key as usize] = -1; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /leetcode/src/d7/_709_to_lower_case.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | #[allow(clippy::wrong_self_convention)] 4 | impl Solution { 5 | fn to_lower_case(s: String) -> String { 6 | s.chars() 7 | .map(|c| { 8 | if c as u8 >= b'A' && c as u8 <= b'Z' { 9 | (c as u8 + (b'a' - b'A')) as char 10 | } else { 11 | c 12 | } 13 | }) 14 | .collect() 15 | } 16 | } 17 | 18 | #[test] 19 | fn test() { 20 | assert_eq!( 21 | Solution::to_lower_case("Hello".to_string()), 22 | "hello".to_string() 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /leetcode/src/d7/_714_best_time_to_buy_and_sell_stock_with_transaction_fee.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn max_profit(prices: Vec, fee: i32) -> i32 { 5 | let n = prices.len(); 6 | let mut cash = 0; 7 | let mut hold = -prices[0]; 8 | for i in 1..n { 9 | cash = cash.max(hold + prices[i] - fee); 10 | hold = hold.max(cash - prices[i]); 11 | } 12 | cash 13 | } 14 | } 15 | 16 | #[test] 17 | fn test() { 18 | let prices = vec![1, 3, 2, 8, 4, 9]; 19 | let fee = 2; 20 | let res = 8; 21 | assert_eq!(Solution::max_profit(prices, fee), res); 22 | } 23 | -------------------------------------------------------------------------------- /leetcode/src/d7/_775_global_and_local_inversions.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn is_ideal_permutation(a: Vec) -> bool { 5 | let n = a.len(); 6 | for i in 0..n { 7 | if (a[i] - i as i32).abs() > 1 { 8 | return false; 9 | } 10 | } 11 | true 12 | } 13 | } 14 | 15 | #[test] 16 | fn test() { 17 | let a = vec![1, 0, 2]; 18 | let res = true; 19 | assert_eq!(Solution::is_ideal_permutation(a), res); 20 | let a = vec![1, 2, 0]; 21 | let res = false; 22 | assert_eq!(Solution::is_ideal_permutation(a), res); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d7/_796_rotate_string.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn rotate_string(a: String, b: String) -> bool { 5 | if a.len() != b.len() { 6 | return false; 7 | } 8 | let mut c = "".to_string(); 9 | c += &a; 10 | c += &a; 11 | c.contains(&b) 12 | } 13 | } 14 | 15 | #[test] 16 | fn test() { 17 | let a = "abcde".to_string(); 18 | let b = "cdeab".to_string(); 19 | assert_eq!(Solution::rotate_string(a, b), true); 20 | let a = "abcde".to_string(); 21 | let b = "abced".to_string(); 22 | assert_eq!(Solution::rotate_string(a, b), false); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d8/_810_chalkboard_xor_game.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn xor_game(nums: Vec) -> bool { 5 | let xor = nums.iter().fold(0, |xor, x| xor ^ x); 6 | xor == 0 || nums.len() % 2 == 0 7 | } 8 | } 9 | 10 | #[test] 11 | fn test() { 12 | let nums = vec![1, 1, 2]; 13 | let res = false; 14 | assert_eq!(Solution::xor_game(nums), res); 15 | } 16 | -------------------------------------------------------------------------------- /leetcode/src/d8/_836_rectangle_overlap.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn is_rectangle_overlap(rec1: Vec, rec2: Vec) -> bool { 5 | rec1[2] > rec2[0] && rec1[0] < rec2[2] && rec1[1] < rec2[3] && rec1[3] > rec2[1] 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | let rec1 = vec![0, 0, 2, 2]; 12 | let rec2 = vec![1, 1, 3, 3]; 13 | assert_eq!(Solution::is_rectangle_overlap(rec1, rec2), true); 14 | let rec1 = vec![0, 0, 1, 1]; 15 | let rec2 = vec![1, 0, 2, 1]; 16 | assert_eq!(Solution::is_rectangle_overlap(rec1, rec2), false); 17 | } 18 | -------------------------------------------------------------------------------- /leetcode/src/d8/_858_mirror_reflection.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn mirror_reflection(mut p: i32, mut q: i32) -> i32 { 5 | while p % 2 == 0 && q % 2 == 0 { 6 | p /= 2; 7 | q /= 2; 8 | } 9 | if p % 2 == 0 { 10 | return 2; 11 | } 12 | if q % 2 == 0 { 13 | return 0; 14 | } 15 | 1 16 | } 17 | } 18 | 19 | #[test] 20 | fn test() { 21 | let p = 2; 22 | let q = 1; 23 | let res = 2; 24 | assert_eq!(Solution::mirror_reflection(p, q), res); 25 | } 26 | -------------------------------------------------------------------------------- /leetcode/src/d8/_877_stone_game.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn stone_game(_: Vec) -> bool { 5 | true 6 | } 7 | } 8 | 9 | #[test] 10 | fn test() { 11 | let piles = vec![5, 3, 4, 5]; 12 | let res = true; 13 | assert_eq!(Solution::stone_game(piles), res); 14 | } 15 | -------------------------------------------------------------------------------- /leetcode/src/d9/_912_sort_an_array.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn sort_array(mut nums: Vec) -> Vec { 5 | nums.sort_unstable(); 6 | nums 7 | } 8 | } 9 | 10 | #[test] 11 | fn test() { 12 | let nums = vec![5, 2, 3, 1]; 13 | let res = vec![1, 2, 3, 5]; 14 | assert_eq!(Solution::sort_array(nums), res); 15 | let nums = vec![5, 1, 1, 2, 0, 0]; 16 | let res = vec![0, 0, 1, 1, 2, 5]; 17 | assert_eq!(Solution::sort_array(nums), res); 18 | } 19 | -------------------------------------------------------------------------------- /leetcode/src/d9/_932_beautiful_array.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn beautiful_array(n: i32) -> Vec { 5 | if n == 1 { 6 | vec![1] 7 | } else { 8 | let left = Self::beautiful_array(n / 2); 9 | let right = Self::beautiful_array((n + 1) / 2); 10 | left.into_iter() 11 | .map(|x| x * 2) 12 | .chain(right.into_iter().map(|x| x * 2 - 1)) 13 | .collect() 14 | } 15 | } 16 | } 17 | 18 | #[test] 19 | fn test() { 20 | let n = 4; 21 | let res = vec![4, 2, 3, 1]; 22 | assert_eq!(Solution::beautiful_array(n), res); 23 | } 24 | -------------------------------------------------------------------------------- /leetcode/src/d9/_977_squares_of_a_sorted_array.rs: -------------------------------------------------------------------------------- 1 | struct Solution; 2 | 3 | impl Solution { 4 | fn sorted_squares(a: Vec) -> Vec { 5 | let mut squared: Vec = a.iter().map(|a| a * a).collect(); 6 | squared.sort_unstable(); 7 | squared 8 | } 9 | } 10 | 11 | #[test] 12 | fn test() { 13 | assert_eq!( 14 | Solution::sorted_squares(vec![-4, -1, 0, 3, 10]), 15 | vec![0, 1, 9, 16, 100] 16 | ); 17 | assert_eq!( 18 | Solution::sorted_squares(vec![-7, -3, 2, 3, 11]), 19 | vec![4, 9, 9, 49, 121] 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /metaldnn-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "metaldnn-sys" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | [dependencies] 8 | block = "0.1.6" 9 | objc = { version = "0.2.7", features = ["objc_exception"] } 10 | 11 | [build-dependencies] 12 | cc = { version = "1.0", features = ["parallel"] } 13 | bindgen = "0.59.1" 14 | -------------------------------------------------------------------------------- /metaldnn-sys/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_camel_case_types)] 2 | #![allow(non_snake_case)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(improper_ctypes)] 5 | #![allow(unaligned_references)] 6 | include!(concat!(env!("OUT_DIR"), "/bindings.rs")); 7 | -------------------------------------------------------------------------------- /metaldnn-sys/src/wrapper.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /metaldnn/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "metaldnn" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | [dependencies] 8 | once_cell = "1.8.0" 9 | metaldnn-sys = { path = "../metaldnn-sys" } 10 | derivative = "2.2.0" 11 | objc = { version = "0.2.7", features = ["objc_exception"] } 12 | 13 | [build-dependencies] 14 | cc = { version = "1.0", features = ["parallel"] } 15 | bindgen = "0.59.1" 16 | -------------------------------------------------------------------------------- /metaldnn/src/dnn.rs: -------------------------------------------------------------------------------- 1 | // use crate::layer::*; 2 | 3 | #[derive(Debug)] 4 | pub struct Dnn { 5 | // #[derivative(Debug = "ignore")] 6 | // device: StrongPtr, 7 | // #[derivative(Debug = "ignore")] 8 | // layers: Vec>, 9 | } 10 | 11 | impl Dnn { 12 | pub fn new() -> Self { 13 | // let layers = vec![]; 14 | Dnn { 15 | // layers, 16 | } 17 | } 18 | 19 | // pub fn sequential_model(&mut self, layers: Vec>) { 20 | // for mut layer in layers { 21 | // // layer.init_with_device(self.device); 22 | // self.layers.push(layer); 23 | // } 24 | // } 25 | } 26 | -------------------------------------------------------------------------------- /metaldnn/src/ios.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @interface MyView : UIView 6 | 7 | @end 8 | 9 | @implementation MyView 10 | + (Class)layerClass { 11 | return [CAMetalLayer class]; 12 | } 13 | @end 14 | 15 | CAMetalLayer *layer_init(void *window_view, id device) { 16 | UIView *view = (UIView *)window_view; 17 | CAMetalLayer *metal_layer = (CAMetalLayer *)view.layer; 18 | return metal_layer; 19 | } 20 | -------------------------------------------------------------------------------- /metaldnn/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate objc; 3 | 4 | mod dnn; 5 | mod layer; 6 | mod metaldnn; 7 | 8 | pub use dnn::*; 9 | pub use layer::*; 10 | pub use metaldnn::*; 11 | pub use metaldnn_sys::*; 12 | -------------------------------------------------------------------------------- /metaldnn/src/macos.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | CAMetalLayer *layer_init(void *window_view, id device) { 5 | NSView *view = (NSView *)window_view; 6 | view.wantsLayer = YES; 7 | view.layer = [CAMetalLayer layer]; 8 | CAMetalLayer *metal_layer = (CAMetalLayer *)view.layer; 9 | metal_layer.device = device; 10 | NSLog(@"CAMetalLayer %@", metal_layer); 11 | return metal_layer; 12 | } -------------------------------------------------------------------------------- /migrations/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/migrations/.gitkeep -------------------------------------------------------------------------------- /migrations/2020-12-13-194959_create_leetcode_question/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` -------------------------------------------------------------------------------- /migrations/2020-12-13-194959_create_leetcode_question/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE leetcode_question ( 2 | id INTEGER NOT NULL PRIMARY KEY, 3 | title TEXT NOT NULL, 4 | slug TEXT NOT NULL, 5 | level INTEGER NOT NULL 6 | ); 7 | -------------------------------------------------------------------------------- /migrations/2020-12-15-091647_create_leetcode_description/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` -------------------------------------------------------------------------------- /migrations/2020-12-15-091647_create_leetcode_description/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE leetcode_description ( 2 | id INTEGER PRIMARY KEY 3 | NOT NULL 4 | REFERENCES leetcode_question (id), 5 | filename TEXT NOT NULL, 6 | html TEXT NOT NULL 7 | ); 8 | -------------------------------------------------------------------------------- /migrations/2020-12-16-011639_create_leetcode_solution/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` -------------------------------------------------------------------------------- /migrations/2020-12-16-011639_create_leetcode_solution/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE leetcode_solution ( 2 | question_id INTEGER NOT NULL 3 | REFERENCES leetcode_question (id), 4 | filename TEXT NOT NULL 5 | PRIMARY KEY, 6 | source TEXT NOT NULL 7 | ); 8 | -------------------------------------------------------------------------------- /migrations/2020-12-19-071746_create_adventofcode_description/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` -------------------------------------------------------------------------------- /migrations/2020-12-19-071746_create_adventofcode_description/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE adventofcode_description ( 2 | id INTEGER PRIMARY KEY 3 | NOT NULL, 4 | year INTEGER NOT NULL, 5 | day INTEGER NOT NULL, 6 | title TEXT NOT NULL, 7 | filename TEXT NOT NULL, 8 | html TEXT NOT NULL 9 | ); 10 | -------------------------------------------------------------------------------- /migrations/2020-12-19-081420_create_adventofcode_solution/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` -------------------------------------------------------------------------------- /migrations/2020-12-19-081420_create_adventofcode_solution/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE adventofcode_solution ( 2 | id INTEGER PRIMARY KEY 3 | NOT NULL, 4 | year INTEGER NOT NULL, 5 | day INTEGER NOT NULL, 6 | filename TEXT NOT NULL, 7 | source TEXT NOT NULL 8 | ); 9 | -------------------------------------------------------------------------------- /migrations/2021-03-16-194853_create_google_problem/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` -------------------------------------------------------------------------------- /migrations/2021-03-16-194853_create_google_problem/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE google_problem ( 2 | id INTEGER PRIMARY KEY 3 | NOT NULL, 4 | division INTEGER NOT NULL, 5 | year INTEGER NOT NULL, 6 | round INTEGER NOT NULL, 7 | number INTEGER NOT NULL, 8 | title TEXT NOT NULL, 9 | problem TEXT NOT NULL, 10 | input TEXT NOT NULL, 11 | output TEXT NOT NULL, 12 | solution TEXT NOT NULL, 13 | analysis TEXT NOT NULL 14 | ); 15 | -------------------------------------------------------------------------------- /migrations/2021-12-20-232817_create-nes-rom/down.sql: -------------------------------------------------------------------------------- 1 | -- This file should undo anything in `up.sql` -------------------------------------------------------------------------------- /migrations/2021-12-20-232817_create-nes-rom/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE nes_rom ( 2 | id INTEGER PRIMARY KEY 3 | NOT NULL, 4 | title TEXT NOT NULL, 5 | description TEXT NOT NULL, 6 | filename TEXT NOT NULL, 7 | image TEXT NOT NULL, 8 | size INTEGER NOT NULL, 9 | md5 TEXT NOT NULL 10 | ); 11 | -------------------------------------------------------------------------------- /mnist-data/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym-mnist-data" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | [dependencies] 8 | serde = { version = "1.0.130", features = ["derive"] } 9 | bincode = "1.3.3" 10 | 11 | [build-dependencies] 12 | bincode = "1.3.3" 13 | curl = "0.4.38" 14 | flate2 = "1.0.22" 15 | serde = { version = "1.0.130", features = ["derive"] } 16 | -------------------------------------------------------------------------------- /mnist/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mnist" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | [dependencies] 8 | metaldnn = { path = "../metaldnn" } 9 | rustgym-mnist-data = { path = "../mnist-data" } 10 | winit = "0.25.0" 11 | objc = { version = "0.2.7", features = ["objc_exception"] } 12 | gilrs = "0.8.1" 13 | png = "0.17.2" 14 | 15 | [lib] 16 | name = "mnist" 17 | crate-type = ["staticlib"] 18 | -------------------------------------------------------------------------------- /mnist/gfx-rs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/mnist/gfx-rs.png -------------------------------------------------------------------------------- /mnist/src/main.rs: -------------------------------------------------------------------------------- 1 | mod lib; 2 | use lib::mainloop; 3 | 4 | fn main() { 5 | mainloop(); 6 | } 7 | -------------------------------------------------------------------------------- /msg/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym-msg" 3 | version = "0.1.0" 4 | authors = ["Larry Fantasy "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | [dependencies] 9 | serde = { version = "1.0.119", features = ["derive"] } 10 | serde_json = "1.0.61" 11 | uuid = { version = "0.8", features = ["serde", "v4"] } 12 | derive-new = "0.5.8" 13 | uaparser = "0.4.0" 14 | bytes = "1.0.1" 15 | js-sys = "0.3.51" 16 | web-sys = { version = "0.3.51", features = ["RtcIceCandidateInit"] } 17 | -------------------------------------------------------------------------------- /nes/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nes" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | [dependencies] 8 | bitflags = "1.3.2" 9 | colored = "2.0.0" 10 | crc = "2.1.0" 11 | env_logger = "0.9.0" 12 | log = "0.4.14" 13 | md5 = "0.7.0" 14 | rand = "0.8.4" 15 | -------------------------------------------------------------------------------- /nes/src/apu.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | use log::info; 3 | 4 | #[derive(Debug, Default)] 5 | pub struct Apu {} 6 | 7 | impl MemoryHandler for Apu { 8 | fn read_byte(&mut self, addr: u16) -> u8 { 9 | 0 10 | } 11 | 12 | fn write_byte(&mut self, addr: u16, byte: u8) {} 13 | } 14 | 15 | impl Apu { 16 | pub fn process_cpu_clock(&mut self) { 17 | // todo!() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /nes/src/auto_save_manager.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct AutoSaveManager {} 3 | -------------------------------------------------------------------------------- /nes/src/battery_manager.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct BatteryManager {} 3 | -------------------------------------------------------------------------------- /nes/src/breakpoint.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct Breakpoint {} 3 | 4 | impl Breakpoint {} 5 | 6 | pub enum BreakpointType { 7 | Global, 8 | Execute, 9 | ReadRam, 10 | WriteRam, 11 | ReadVram, 12 | WriteVram, 13 | DummyReadRam, 14 | DummyWriteRam, 15 | } 16 | 17 | impl BreakpointType { 18 | pub const COUNT: usize = 8; 19 | } 20 | -------------------------------------------------------------------------------- /nes/src/cheat_manager.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct CheatManager {} 3 | -------------------------------------------------------------------------------- /nes/src/code_data_logger.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct CodeDataLogger {} 3 | -------------------------------------------------------------------------------- /nes/src/code_runner.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct CodeRunner {} 3 | -------------------------------------------------------------------------------- /nes/src/console_features.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct ConsoleFeatures {} 3 | -------------------------------------------------------------------------------- /nes/src/debug_hud.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct DebugHud {} 3 | -------------------------------------------------------------------------------- /nes/src/disassembler.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct Disassembler {} 3 | -------------------------------------------------------------------------------- /nes/src/dummy_cpu.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct DummyCpu {} 3 | -------------------------------------------------------------------------------- /nes/src/event_manager.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct EventManager {} 3 | -------------------------------------------------------------------------------- /nes/src/expression_data.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct ExpressionData {} 3 | -------------------------------------------------------------------------------- /nes/src/expression_evaluator.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct ExpressionEvaluator {} 3 | -------------------------------------------------------------------------------- /nes/src/frame_info.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct FrameInfo { 3 | width: usize, 4 | height: usize, 5 | original_width: usize, 6 | original_height: usize, 7 | bits_per_pixel: usize, 8 | } 9 | -------------------------------------------------------------------------------- /nes/src/history_viewer.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct HistoryViewer {} 3 | -------------------------------------------------------------------------------- /nes/src/hook.rs: -------------------------------------------------------------------------------- 1 | pub trait Hook { 2 | fn execute(&self); 3 | } 4 | -------------------------------------------------------------------------------- /nes/src/instruction_progress.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct InstructionProgress {} 3 | -------------------------------------------------------------------------------- /nes/src/label_manager.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct LabelManager {} 3 | -------------------------------------------------------------------------------- /nes/src/logger.rs: -------------------------------------------------------------------------------- 1 | use std::io::Write; 2 | use std::sync::Once; 3 | 4 | static INIT: Once = Once::new(); 5 | 6 | pub fn logger_init() { 7 | INIT.call_once(|| { 8 | env_logger::builder() 9 | .format(|buf, record| { 10 | writeln!( 11 | buf, 12 | "[{} {}:{}] - {}", 13 | buf.default_styled_level(record.level()), 14 | record.file().unwrap(), 15 | record.line().unwrap(), 16 | record.args() 17 | ) 18 | }) 19 | .init(); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /nes/src/memory_access_counter.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct MemoryAccessCounter {} 3 | -------------------------------------------------------------------------------- /nes/src/memory_dumper.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct MemoryDumper {} 3 | -------------------------------------------------------------------------------- /nes/src/notification_manager.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct NotificationManager {} 3 | -------------------------------------------------------------------------------- /nes/src/operation_info.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct OperationInfo {} 3 | -------------------------------------------------------------------------------- /nes/src/performance_tracker.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct PerformanceTracker {} 3 | -------------------------------------------------------------------------------- /nes/src/profiler.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct Profiler {} 3 | -------------------------------------------------------------------------------- /nes/src/rewind_manager.rs: -------------------------------------------------------------------------------- 1 | use crate::ControlManager; 2 | 3 | #[derive(Default)] 4 | pub struct RewindManager {} 5 | 6 | impl RewindManager { 7 | pub fn new() -> Self { 8 | let this = RewindManager::default(); 9 | this 10 | } 11 | 12 | pub fn send_frame(&mut self, ppu_output_buffer: &mut Vec, synchronous: bool) { 13 | todo!() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /nes/src/rotate_filter.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct RotateFilter {} 3 | -------------------------------------------------------------------------------- /nes/src/save_state_manager.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct SaveStateManager {} 3 | -------------------------------------------------------------------------------- /nes/src/scale_filter.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct ScaleFilter {} 3 | -------------------------------------------------------------------------------- /nes/src/screen.rs: -------------------------------------------------------------------------------- 1 | pub const WIDTH: usize = 256; 2 | pub const HEIGHT: usize = 240; 3 | pub const PIXELS: usize = WIDTH * HEIGHT; 4 | pub const PALETTE: usize = 64 * 8; 5 | 6 | struct Screen { 7 | pixels: [u16; PIXELS], 8 | palette: [u32; PALETTE], 9 | } 10 | -------------------------------------------------------------------------------- /nes/src/sound.rs: -------------------------------------------------------------------------------- 1 | pub trait Sound {} 2 | -------------------------------------------------------------------------------- /nes/src/sound_mixer.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct SoundMixer {} 3 | -------------------------------------------------------------------------------- /nes/src/stack_frame_flags.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct StackFrameFlags {} 3 | -------------------------------------------------------------------------------- /nes/src/stack_frame_info.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct StackFrameInfo {} 3 | -------------------------------------------------------------------------------- /nes/src/system_action_manager.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct SystemActionManager {} 3 | -------------------------------------------------------------------------------- /nes/src/timer.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct Timer; 3 | -------------------------------------------------------------------------------- /nes/src/trace_logger.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct TraceLogger {} 3 | -------------------------------------------------------------------------------- /nes/src/video_filter/default_video_filter.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | pub struct DefaultVideoFilter { 3 | base_video_filter: BaseVideoFilter, 4 | } 5 | 6 | impl VideoFilter for DefaultVideoFilter { 7 | fn base_video_filter(&self) -> &BaseVideoFilter { 8 | &self.base_video_filter 9 | } 10 | 11 | fn base_video_filter_mut(&mut self) -> &mut BaseVideoFilter { 12 | &mut self.base_video_filter 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /nes/src/video_hud.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct VideoHud; 3 | -------------------------------------------------------------------------------- /nes/src/video_renderer.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | 3 | #[derive(Default)] 4 | pub struct VideoRenderer { 5 | renderer: Option>, 6 | } 7 | 8 | impl VideoRenderer { 9 | pub fn new(renderer: Box) -> Self { 10 | let mut this = VideoRenderer::default(); 11 | this.renderer = Some(renderer); 12 | this 13 | } 14 | 15 | pub fn update_frame(&self, framebuffer: &mut [u8], width: usize, height: usize) { 16 | if let Some(renderer) = self.renderer.as_ref() { 17 | renderer.update_frame(framebuffer, width, height); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /nes/src/virtual_file.rs: -------------------------------------------------------------------------------- 1 | #[derive(Default)] 2 | pub struct VirtualFile { 3 | pub filename: String, 4 | pub data: Vec, 5 | } 6 | 7 | impl VirtualFile { 8 | pub fn new(filename: &str, data: &[u8]) -> Self { 9 | let data = data.to_vec(); 10 | let filename = filename.to_string(); 11 | VirtualFile { filename, data } 12 | } 13 | pub fn is_valid(&self) -> bool { 14 | self.data.len() > 0 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /nes/test/nestest.nes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/nes/test/nestest.nes -------------------------------------------------------------------------------- /openvgdb/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "openvgdb" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | [dependencies] 8 | md5 = "0.7.0" 9 | diesel = { version = "1.4.8", features = [ 10 | "sqlite", 11 | "r2d2", 12 | "chrono", 13 | "uuidv07" 14 | ] } 15 | rustgym-consts = { path = "../consts" } 16 | rustgym-schema = { path = "../schema" } 17 | -------------------------------------------------------------------------------- /openvgdb/src/main.rs: -------------------------------------------------------------------------------- 1 | use diesel::insert_into; 2 | use diesel::prelude::*; 3 | use diesel::sqlite::SqliteConnection; 4 | use openvgdb::get_nes_roms; 5 | use rustgym_consts::*; 6 | use rustgym_schema::*; 7 | 8 | fn main() { 9 | let conn = SqliteConnection::establish(DATABASE_URL).unwrap(); 10 | use schema::nes_rom::dsl::*; 11 | let roms = get_nes_roms(); 12 | let n = insert_into(nes_rom).values(&roms).execute(&conn).unwrap(); 13 | assert_eq!(n, roms.len()); 14 | } 15 | -------------------------------------------------------------------------------- /openvgdb/src/rom.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, Queryable)] 2 | pub struct RomData { 3 | pub romID: Option, 4 | pub releaseTitleName: Option, 5 | pub releaseDescription: Option, 6 | pub romHashMD5: Option, 7 | pub romFileName: Option, 8 | pub releaseCoverFront: Option, 9 | pub romSize: Option, 10 | } 11 | -------------------------------------------------------------------------------- /rustgym/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym" 3 | version = "0.2.0" 4 | authors = ["Yinchu Xia "] 5 | edition = "2018" 6 | license = "MIT OR Apache-2.0" 7 | description = "rustgym solutions" 8 | repository = "https://github.com/warycat/rustgym" 9 | readme = "../README.md" 10 | 11 | [package.metadata.docs.rs] 12 | no-default-features = true 13 | 14 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 15 | [features] 16 | default = [] 17 | 18 | [dependencies] 19 | rand = "0.7.3" 20 | pretty_assertions = "0.6.1" 21 | assert_approx_eq = "1.1.0" 22 | rustgym-util = { path = "../util" } 23 | -------------------------------------------------------------------------------- /schema/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym-schema" 3 | version = "0.1.0" 4 | authors = ["Yinchu Xia "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | [dependencies] 9 | diesel = { version = "1.4.8", features = [ 10 | "sqlite", 11 | "r2d2", 12 | "chrono", 13 | "uuidv07" 14 | ] } 15 | rustgym-consts = { path = "../consts" } 16 | serde = "1.0.118" 17 | derive-new = "0.5.8" 18 | regex = "1.4.2" 19 | -------------------------------------------------------------------------------- /schema/src/adventofcode_solution.rs: -------------------------------------------------------------------------------- 1 | use crate::schema::adventofcode_solution; 2 | 3 | #[derive(Debug, Queryable, Insertable, new)] 4 | #[table_name = "adventofcode_solution"] 5 | pub struct AdventOfCodeSolution { 6 | pub id: i32, 7 | pub year: i32, 8 | pub day: i32, 9 | filename: String, 10 | pub source: String, 11 | } 12 | -------------------------------------------------------------------------------- /schema/src/leetcode_description.rs: -------------------------------------------------------------------------------- 1 | use crate::schema::leetcode_description; 2 | use rustgym_consts::*; 3 | use std::fmt; 4 | 5 | #[derive(Debug, Queryable, Insertable, new)] 6 | #[table_name = "leetcode_description"] 7 | pub struct LeetcodeDescription { 8 | pub id: i32, 9 | filename: String, 10 | pub html: String, 11 | } 12 | 13 | impl fmt::Display for LeetcodeDescription { 14 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 15 | write!(f, "[{}]({}/{})", self.id, LEETCODE_DESC, self.filename) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /schema/src/leetcode_solution.rs: -------------------------------------------------------------------------------- 1 | use crate::schema::leetcode_solution; 2 | use rustgym_consts::*; 3 | use std::fmt; 4 | 5 | #[derive(Debug, Queryable, Insertable, new)] 6 | #[table_name = "leetcode_solution"] 7 | pub struct LeetcodeSolution { 8 | pub question_id: i32, 9 | filename: String, 10 | pub source: String, 11 | } 12 | 13 | impl fmt::Display for LeetcodeSolution { 14 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 15 | write!(f, "[Rust]({}/{})", LEETCODE_SRC, self.filename) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /schema/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate diesel; 3 | 4 | #[macro_use] 5 | extern crate derive_new; 6 | 7 | mod adventofcode_description; 8 | mod adventofcode_solution; 9 | mod google_problem; 10 | mod leetcode_description; 11 | mod leetcode_question; 12 | mod leetcode_solution; 13 | mod nes_rom; 14 | pub mod schema; 15 | 16 | pub use adventofcode_description::*; 17 | pub use adventofcode_solution::*; 18 | pub use google_problem::*; 19 | pub use leetcode_description::*; 20 | pub use leetcode_question::*; 21 | pub use leetcode_solution::*; 22 | pub use nes_rom::*; 23 | -------------------------------------------------------------------------------- /schema/src/nes_rom.rs: -------------------------------------------------------------------------------- 1 | use crate::schema::nes_rom; 2 | use rustgym_consts::*; 3 | use std::fmt; 4 | 5 | #[derive(Debug, Queryable, Insertable, new)] 6 | #[table_name = "nes_rom"] 7 | pub struct NesRom { 8 | pub id: i32, 9 | pub title: String, 10 | pub description: String, 11 | pub filename: String, 12 | pub image: String, 13 | pub size: i32, 14 | pub md5: String, 15 | } 16 | 17 | impl fmt::Display for NesRom { 18 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 19 | write!(f, "[Rust]({}/{})", LEETCODE_SRC, self.filename) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /scripts/.gitignore: -------------------------------------------------------------------------------- 1 | ignore.env 2 | 3 | -------------------------------------------------------------------------------- /scripts/certbot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | certbot certonly --register-unsafely-without-email --standalone -------------------------------------------------------------------------------- /scripts/coturn.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | turnserver -n --verbose --use-auth-secret --fingerprint \ 3 | --static-auth-secret=$TURN_STATIC_AUTH_SECRET \ 4 | --realm=$TURN_REALM \ 5 | --external-ip=$TURN_EXTERNAL_IP \ 6 | --cert=$TURN_CERT \ 7 | --pkey=$TURN_PKEY \ 8 | --cli-password=$TURN_CLI_PASSWORD \ 9 | 2>&1 >> log/turnserver.log & -------------------------------------------------------------------------------- /scripts/create_stun_firewall_rule.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source infra/const.env 3 | 4 | gcloud compute firewall-rules create allow-stun \ 5 | --allow tcp:$TURN_LISTENING_PORT,udp:$TURN_LISTENING_PORT,tcp:$TURN_TLS_LISTENING_PORT,udp:$TURN_TLS_LISTENING_PORT,tcp:$TURN_MIN_PORT-$TURN_MAX_PORT,udp:$TURN_MIN_PORT-$TURN_MAX_PORT \ 6 | --target-tags stun-server \ 7 | -------------------------------------------------------------------------------- /scripts/envoy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | envoy -c config/envoy.yaml 2>&1 >> log/envoy.log & -------------------------------------------------------------------------------- /scripts/ingest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ./rustgym-ingest 2>&1 >> log/ingest.log & 3 | -------------------------------------------------------------------------------- /scripts/server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "starting rustgym server" 3 | TAG=$TAG TURN_STATIC_AUTH_SECRET=$TURN_STATIC_AUTH_SECRET RUST_LOG=INFO ./rustgym-server 2>&1 >> log/server.log & 4 | -------------------------------------------------------------------------------- /scripts/sonic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "starting sonic server" 3 | ./sonic-server -c config/sonic.cfg 2>&1 >> log/sonic.log & -------------------------------------------------------------------------------- /server/src/agents/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod envelope; 2 | pub mod registry; 3 | pub mod search; 4 | pub mod uap; 5 | pub mod websocket; 6 | -------------------------------------------------------------------------------- /server/src/context/app.rs: -------------------------------------------------------------------------------- 1 | use crate::context::*; 2 | 3 | pub struct AppContext { 4 | pub title: String, 5 | pub tag: String, 6 | } 7 | 8 | impl AppContext { 9 | pub fn new(data: Data) -> Self { 10 | let title = data.title.borrow().to_string(); 11 | let tag = data.tag.borrow().to_string(); 12 | AppContext { title, tag } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /server/src/context/find.rs: -------------------------------------------------------------------------------- 1 | use crate::context::*; 2 | 3 | #[derive(Template, new)] 4 | #[template(path = "find.j2")] 5 | pub struct FindContext { 6 | pub app: AppContext, 7 | pub session: SessionData, 8 | pub path: String, 9 | } 10 | -------------------------------------------------------------------------------- /server/src/context/home.rs: -------------------------------------------------------------------------------- 1 | use crate::context::*; 2 | 3 | #[derive(Template, new)] 4 | #[template(path = "home.j2")] 5 | pub struct HomeContext { 6 | pub app: AppContext, 7 | pub session: SessionData, 8 | pub path: String, 9 | } 10 | -------------------------------------------------------------------------------- /server/src/context/sitemap.rs: -------------------------------------------------------------------------------- 1 | use askama::Template; 2 | use rustgym_schema::*; 3 | 4 | #[derive(Template, new)] 5 | #[template(path = "sitemap.j2")] 6 | pub struct SitemapContext { 7 | pub leetcode_rows: Vec, 8 | pub adventofcode_rows: Vec, 9 | pub google_rows: Vec, 10 | } 11 | 12 | #[derive(Template, new)] 13 | #[template(path = "robots.j2")] 14 | pub struct RobotsContext {} 15 | -------------------------------------------------------------------------------- /server/src/routes/find.rs: -------------------------------------------------------------------------------- 1 | use crate::app_data::AppData; 2 | use crate::context::*; 3 | use crate::session_data::update_session; 4 | use actix_session::Session; 5 | use actix_web::get; 6 | use actix_web::web; 7 | use actix_web::Error; 8 | use actix_web::HttpRequest; 9 | use actix_web::HttpResponse; 10 | 11 | #[get("/find")] 12 | pub async fn find( 13 | req: HttpRequest, 14 | data: web::Data, 15 | session: Session, 16 | ) -> Result { 17 | let session_data = update_session(session)?; 18 | FindContext::new(AppContext::new(data), session_data, req.path().to_string()).render_wrapper() 19 | } 20 | -------------------------------------------------------------------------------- /server/src/routes/home.rs: -------------------------------------------------------------------------------- 1 | use crate::app_data::AppData; 2 | use crate::context::*; 3 | use crate::session_data::update_session; 4 | use actix_session::Session; 5 | use actix_web::get; 6 | use actix_web::web; 7 | use actix_web::Error; 8 | use actix_web::HttpRequest; 9 | use actix_web::HttpResponse; 10 | 11 | #[get("/")] 12 | pub async fn home( 13 | req: HttpRequest, 14 | data: web::Data, 15 | session: Session, 16 | ) -> Result { 17 | let session_data = update_session(session)?; 18 | HomeContext::new(AppContext::new(data), session_data, req.path().to_string()).render_wrapper() 19 | } 20 | -------------------------------------------------------------------------------- /server/src/routes/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod adventofcode_detail; 2 | pub mod adventofcode_index; 3 | pub mod find; 4 | pub mod google_detail; 5 | pub mod google_index; 6 | pub mod home; 7 | pub mod leetcode_detail; 8 | pub mod leetcode_index; 9 | pub mod nes_detail; 10 | pub mod nes_index; 11 | pub mod robots; 12 | pub mod sitemap; 13 | -------------------------------------------------------------------------------- /server/src/routes/robots.rs: -------------------------------------------------------------------------------- 1 | use crate::context::*; 2 | use actix_web::get; 3 | use actix_web::Error; 4 | use actix_web::HttpResponse; 5 | 6 | #[get("/robots.txt")] 7 | pub async fn robots_txt() -> Result { 8 | RobotsContext::new().render_wrapper() 9 | } 10 | -------------------------------------------------------------------------------- /server/templates/robots.j2: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: / 3 | 4 | Sitemap: https://rustgym.com/sitemap.txt 5 | -------------------------------------------------------------------------------- /server/templates/sitemap.j2: -------------------------------------------------------------------------------- 1 | https://rustgym.com 2 | https://rustgym.com/leetcode 3 | {%- for row in leetcode_rows %} 4 | https://rustgym.com/leetcode/{{row.id}} 5 | {%- endfor %} 6 | https://rustgym.com/adventofcode 7 | {%- for row in adventofcode_rows %} 8 | https://rustgym.com{{row.href()|safe}} 9 | {%- endfor %} 10 | https://rustgym.com/google 11 | {%- for row in google_rows %} 12 | https://rustgym.com{{row.href()|safe}} 13 | {%- endfor %} 14 | -------------------------------------------------------------------------------- /static/css/ms_sans_serif.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/css/ms_sans_serif.woff2 -------------------------------------------------------------------------------- /static/css/ms_sans_serif_bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/css/ms_sans_serif_bold.woff2 -------------------------------------------------------------------------------- /static/gif/documents.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/gif/documents.gif -------------------------------------------------------------------------------- /static/gif/exe.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/gif/exe.gif -------------------------------------------------------------------------------- /static/gif/favourites.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/gif/favourites.gif -------------------------------------------------------------------------------- /static/gif/find.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/gif/find.gif -------------------------------------------------------------------------------- /static/gif/help.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/gif/help.gif -------------------------------------------------------------------------------- /static/gif/logoff.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/gif/logoff.gif -------------------------------------------------------------------------------- /static/gif/programs.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/gif/programs.gif -------------------------------------------------------------------------------- /static/gif/run.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/gif/run.gif -------------------------------------------------------------------------------- /static/gif/settings.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/gif/settings.gif -------------------------------------------------------------------------------- /static/gif/shutdown.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/gif/shutdown.gif -------------------------------------------------------------------------------- /static/gif/txt.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/gif/txt.gif -------------------------------------------------------------------------------- /static/ico/executable.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/ico/executable.ico -------------------------------------------------------------------------------- /static/ico/loudspeaker_rays.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/ico/loudspeaker_rays.ico -------------------------------------------------------------------------------- /static/ico/user_world.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/ico/user_world.ico -------------------------------------------------------------------------------- /static/ico/windows.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/static/ico/windows.ico -------------------------------------------------------------------------------- /util/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustgym-util" 3 | version = "0.2.4" 4 | authors = ["Yinchu Xia "] 5 | edition = "2018" 6 | license = "MIT OR Apache-2.0" 7 | description = "handy macros, data types and traits for rustgym" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | -------------------------------------------------------------------------------- /util/src/data.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] 2 | macro_rules! vec_vec_i32 { 3 | ($($tail:tt),*) => { 4 | vec![$(vec!$tail),*] as Vec> 5 | }; 6 | } 7 | 8 | #[macro_export] 9 | macro_rules! vec_string { 10 | ($($tail:tt),*) => { 11 | vec![$($tail.to_string()),*] as Vec 12 | }; 13 | } 14 | 15 | #[macro_export] 16 | macro_rules! vec_vec_string { 17 | ($($tail:tt),*) => { 18 | vec![$(vec_string!$tail),*] as Vec> 19 | }; 20 | } 21 | 22 | #[macro_export] 23 | macro_rules! vec_vec_char { 24 | ($($tail:tt),*) => { 25 | vec![$(vec!$tail),*] as Vec> 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /util/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod adventofcode; 2 | mod data; 3 | mod graph; 4 | mod list; 5 | mod nested_integer; 6 | mod read; 7 | mod test_gen; 8 | mod tree; 9 | mod unionfind; 10 | 11 | pub use crate::adventofcode::*; 12 | pub use crate::data::*; 13 | pub use crate::graph::*; 14 | pub use crate::list::*; 15 | pub use crate::nested_integer::*; 16 | pub use crate::read::*; 17 | pub use crate::test_gen::*; 18 | pub use crate::tree::*; 19 | pub use crate::unionfind::*; 20 | -------------------------------------------------------------------------------- /util/src/list.rs: -------------------------------------------------------------------------------- 1 | #[derive(PartialEq, Eq, Clone, Debug)] 2 | pub struct ListNode { 3 | pub val: i32, 4 | pub next: ListLink, 5 | } 6 | 7 | #[macro_export] 8 | macro_rules! list { 9 | () => { 10 | None 11 | }; 12 | ($e:expr) => { 13 | ListLink::link($e, None) 14 | }; 15 | ($e:expr, $($tail:tt)*) => { 16 | ListLink::link($e, list!($($tail)*)) 17 | }; 18 | } 19 | 20 | pub type ListLink = Option>; 21 | 22 | pub trait ListMaker { 23 | fn link(val: i32, next: ListLink) -> ListLink { 24 | Some(Box::new(ListNode { val, next })) 25 | } 26 | } 27 | 28 | impl ListMaker for ListLink {} 29 | -------------------------------------------------------------------------------- /wasm/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | Cargo.lock 4 | bin/ 5 | pkg/ 6 | wasm-pack.log 7 | -------------------------------------------------------------------------------- /wasm/cubetexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ua/rustgym_eng/be1ff708f7f7d3eb27e7d7880e7829ab5a0b10c2/wasm/cubetexture.png -------------------------------------------------------------------------------- /wasm/helper.js: -------------------------------------------------------------------------------- 1 | export function constraints() { 2 | return { 3 | video: { 4 | width: {ideal: 320}, 5 | height: {ideal: 240} 6 | }, 7 | audio: true, 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /wasm/shaders/nes.frag: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | precision highp float; 3 | 4 | in vec2 v_tex_coord; 5 | out vec4 FragColor; 6 | uniform sampler2D u_texture; 7 | 8 | void main() { 9 | // uvec2 coord = uvec2(v_tex_coord); 10 | // uint i = coord[1] * 8u + coord[0]; 11 | // vec4 i_color = vec4(u_rgbav[i * 4u], u_rgbav[i * 4u + 1u], 12 | // u_rgbav[i * 4u + 2u], u_rgbav[i * 4u + 3u]); 13 | FragColor = texture(u_texture, v_tex_coord); 14 | } 15 | -------------------------------------------------------------------------------- /wasm/shaders/nes.vert: -------------------------------------------------------------------------------- 1 | #version 300 es 2 | 3 | in uvec2 a_position; 4 | const vec2 u_resolution = vec2(256.0, 256.0); 5 | out vec2 v_tex_coord; 6 | 7 | void main() { 8 | vec2 a_position_f = vec2(a_position); 9 | vec2 zero_to_one = a_position_f / u_resolution; 10 | vec2 zero_to_two = zero_to_one * 2.0; 11 | vec2 clip_space = zero_to_two - 1.0; 12 | v_tex_coord = vec2(a_position_f) / u_resolution; 13 | gl_Position = vec4(clip_space * vec2(1, -1), 0, 1); 14 | } -------------------------------------------------------------------------------- /wasm/webdriver.json: -------------------------------------------------------------------------------- 1 | { 2 | "moz:firefoxOptions": { 3 | "prefs": { 4 | "media.navigator.streams.fake": true, 5 | "media.navigator.permission.disabled": true 6 | }, 7 | "args": [] 8 | }, 9 | "goog:chromeOptions": { 10 | "args": [ 11 | "--use-fake-device-for-media-stream", 12 | "--use-fake-ui-for-media-stream" 13 | ] 14 | } 15 | } --------------------------------------------------------------------------------