DatasetRepo commited on
Commit
63cf3bb
·
verified ·
1 Parent(s): ace9da1

cf801ce923240012fcdf362d277c93169e502580d006b424fe732e7547d7e77e

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +3 -0
  2. count_complete_subarrays_in_an_array/ocaml_tests/main.ml +42 -0
  3. count_complete_subarrays_in_an_array/scala_tests/MySuite.scala +32 -0
  4. count_complete_substrings/haskell_tests/Main.hs +0 -0
  5. count_complete_substrings/java_tests/Main.java +21 -0
  6. count_complete_substrings/meta.json +0 -0
  7. count_complete_substrings/ocaml_tests/main.ml +0 -0
  8. count_complete_substrings/scala_tests/MySuite.scala +0 -0
  9. count_connected_components_in_lcm_graph/haskell_tests/Main.hs +0 -0
  10. count_connected_components_in_lcm_graph/java_tests/Main.java +21 -0
  11. count_connected_components_in_lcm_graph/meta.json +3 -0
  12. count_connected_components_in_lcm_graph/ocaml_tests/main.ml +0 -0
  13. count_connected_components_in_lcm_graph/scala_tests/MySuite.scala +0 -0
  14. count_days_spent_together/.DS_Store +0 -0
  15. count_days_spent_together/haskell_tests/Main.hs +24 -0
  16. count_days_spent_together/java_tests/Main.java +21 -0
  17. count_days_spent_together/meta.json +117 -0
  18. count_days_spent_together/ocaml_tests/main.ml +26 -0
  19. count_days_spent_together/scala_tests/MySuite.scala +12 -0
  20. count_days_without_meetings/haskell_tests/Main.hs +0 -0
  21. count_days_without_meetings/java_tests/Main.java +25 -0
  22. count_days_without_meetings/meta.json +3 -0
  23. count_days_without_meetings/ocaml_tests/main.ml +0 -0
  24. count_days_without_meetings/scala_tests/MySuite.scala +0 -0
  25. count_elements_with_maximum_frequency/haskell_tests/Main.hs +41 -0
  26. count_elements_with_maximum_frequency/java_tests/Main.java +20 -0
  27. count_elements_with_maximum_frequency/meta.json +164 -0
  28. count_elements_with_maximum_frequency/ocaml_tests/main.ml +42 -0
  29. count_elements_with_maximum_frequency/scala_tests/MySuite.scala +32 -0
  30. count_elements_with_strictly_smaller_and_greater_elements/.DS_Store +0 -0
  31. count_elements_with_strictly_smaller_and_greater_elements/haskell_tests/Main.hs +24 -0
  32. count_elements_with_strictly_smaller_and_greater_elements/java_tests/Main.java +21 -0
  33. count_elements_with_strictly_smaller_and_greater_elements/meta.json +501 -0
  34. count_elements_with_strictly_smaller_and_greater_elements/ocaml_tests/main.ml +26 -0
  35. count_elements_with_strictly_smaller_and_greater_elements/scala_tests/MySuite.scala +12 -0
  36. count_equal_and_divisible_pairs_in_an_array/.DS_Store +0 -0
  37. count_equal_and_divisible_pairs_in_an_array/haskell_tests/Main.hs +24 -0
  38. count_equal_and_divisible_pairs_in_an_array/java_tests/Main.java +21 -0
  39. count_equal_and_divisible_pairs_in_an_array/meta.json +576 -0
  40. count_equal_and_divisible_pairs_in_an_array/ocaml_tests/main.ml +26 -0
  41. count_equal_and_divisible_pairs_in_an_array/scala_tests/MySuite.scala +12 -0
  42. count_good_triplets_in_an_array/.DS_Store +0 -0
  43. count_good_triplets_in_an_array/haskell_tests/Main.hs +24 -0
  44. count_good_triplets_in_an_array/java_tests/Main.java +21 -0
  45. count_good_triplets_in_an_array/meta.json +3 -0
  46. count_good_triplets_in_an_array/ocaml_tests/main.ml +26 -0
  47. count_good_triplets_in_an_array/scala_tests/MySuite.scala +12 -0
  48. count_hills_and_valleys_in_an_array/.DS_Store +0 -0
  49. count_hills_and_valleys_in_an_array/haskell_tests/Main.hs +24 -0
  50. count_hills_and_valleys_in_an_array/java_tests/Main.java +21 -0
.gitattributes CHANGED
@@ -74,3 +74,6 @@ check_if_grid_can_be_cut_into_sections/scala_tests/MySuite.scala filter=lfs diff
74
  closest_equal_element_queries/meta.json filter=lfs diff=lfs merge=lfs -text
75
  collect_coins_in_a_tree/meta.json filter=lfs diff=lfs merge=lfs -text
76
  count_array_pairs_divisible_by_k/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
74
  closest_equal_element_queries/meta.json filter=lfs diff=lfs merge=lfs -text
75
  collect_coins_in_a_tree/meta.json filter=lfs diff=lfs merge=lfs -text
76
  count_array_pairs_divisible_by_k/meta.json filter=lfs diff=lfs merge=lfs -text
77
+ count_connected_components_in_lcm_graph/meta.json filter=lfs diff=lfs merge=lfs -text
78
+ count_days_without_meetings/meta.json filter=lfs diff=lfs merge=lfs -text
79
+ count_good_triplets_in_an_array/meta.json filter=lfs diff=lfs merge=lfs -text
count_complete_subarrays_in_an_array/ocaml_tests/main.ml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let countCompleteSubarrays (nums: int list) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 4 (countCompleteSubarrays [1;3;1;2;2])
13
+
14
+ let test2 _ = assert_equal 10 (countCompleteSubarrays [5;5;5;5])
15
+
16
+ let test3 _ = assert_equal 10 (countCompleteSubarrays [985; 684; 1562; 107; 515; 123; 1924; 1501; 1874; 557; 1773; 800; 123; 827; 547; 1285; 357; 194; 227; 396; 192; 751; 72; 918; 1496; 1174; 1325; 1478; 821; 799; 164; 477; 1859; 1431; 302; 1636; 1061; 612; 211; 482; 1891; 898; 378; 1371; 1454; 1034; 1216; 1370; 1014; 1224; 1148; 1453; 1613; 204; 270; 1502; 1472; 1336; 1238; 966; 1761; 424; 642; 1589; 316; 71; 507; 241; 1810; 379; 1680; 1772; 1283; 1521; 1631; 465; 578; 83; 1762; 1435; 1743; 910; 725; 1707; 831; 571; 249; 241; 504; 150; 1239; 895; 1084; 345; 1593; 1420; 969; 640; 171; 1511; 1146; 918; 579; 1756; 753; 289; 6; 880; 777; 1513; 1384; 1928; 895; 854; 1642; 1498; 830; 533; 1050; 1045; 650; 1031; 1729; 381; 209; 1528; 1096; 941; 599; 931; 401; 1011; 1742; 584; 126; 134; 1224; 437; 711; 451; 1954; 1305; 1279; 1222; 1486; 1362; 1618; 1924; 86; 1928; 1401; 1089; 45; 1028; 903; 1626; 1544; 243; 917; 1274; 1475; 382; 1221; 550; 1484; 229; 108; 50; 1621; 1229; 1158; 1633; 1747; 1921; 1309; 418; 1147; 452; 1944; 766; 1006; 283; 159; 144; 1184; 1764; 980; 936; 450; 371; 103; 1735; 2; 857; 1035; 1809; 181; 1887; 997; 349; 1384; 1086; 279; 929; 1777; 1335; 607; 197; 221; 404; 1994; 738; 176; 1159; 1672; 1303; 536; 14; 1524; 1574; 259; 386; 758; 352; 429; 152; 894; 1269; 1814; 1957; 964; 1193; 1938; 2000; 398; 705; 828; 1420; 1328; 312; 1892; 110; 1572; 20; 649; 1156; 891; 979; 1337; 179; 760; 1712; 847; 407; 518; 553; 804; 708; 1914; 871; 453; 622; 987; 1370; 55; 710; 294; 827; 1872; 106; 91; 1695; 633; 301; 877; 64; 1759; 659; 515; 1519; 328; 535; 917; 1384; 607; 278; 512; 676; 480; 283; 1592; 965; 1490; 915; 194; 965; 1636; 86; 33; 1734; 317; 1226; 1802; 872; 983; 1220; 1016; 1963; 484; 1252; 724; 1291; 1189; 971; 239; 1002; 412; 109; 407; 1898; 743; 1048; 1367; 1106; 18; 1520; 1837; 1305; 51; 268; 1602; 1992; 1022; 1649; 1340; 1980; 1893; 1913; 524; 68; 1534; 290; 440; 183; 177; 587; 1553; 1186; 861; 405; 1355; 1386; 1078; 1564; 43; 1647; 1490; 1640; 856; 1510; 1949; 88; 739; 331; 89; 398; 1298; 1014; 970; 581; 1270; 241; 1540; 547; 826; 818; 1744; 555; 1383; 1299; 813; 1011; 550; 1295; 17; 1375; 712; 1679; 1793; 1774; 151; 1651; 1510; 192; 1929; 632; 1500; 992; 742; 1497; 463; 201; 1847; 1027; 1409; 1976; 1267; 402; 1995; 1438; 1397; 1975; 1938; 1826; 67; 1003; 1710; 752; 1996; 516; 1142; 1329; 913; 1332; 824; 1316; 223; 1020; 1610; 1792; 60; 332; 241; 1780; 1116; 423; 1144; 1849; 1305; 597; 112; 1224; 1332; 1207; 1515; 403; 160; 457; 1301; 698; 1983; 1558; 1284; 636; 437; 820; 1082; 1559; 1958; 1599; 1583; 1357; 1393; 1267; 675; 1378; 35; 1751; 1493; 105; 477; 1779; 1512; 1613; 460; 548; 16; 1085; 1142; 332; 161; 1086; 288; 1230; 1001; 419; 403; 356; 552; 877; 1915; 657; 699; 1089; 1093; 178; 1356; 1935; 1835; 1804; 179; 578; 658; 1784; 72; 1696; 841; 1063; 1074; 341; 625; 925; 240; 154; 1974; 1094; 1841; 1987; 334; 1676; 1844; 1302; 1252; 591; 1412; 518; 655; 360; 1753; 982; 240; 866; 629; 1084; 1654; 850; 570; 356; 1320; 1201; 924; 1809; 378; 107; 1907; 441; 1677; 1219; 256; 1033; 1589; 441; 95; 631; 1807; 1714; 994; 933; 1901; 111; 216; 1982; 1848; 465; 1338; 953; 124; 1245; 1811; 1281; 1403; 462; 1343; 728; 901; 132; 1311; 1570; 136; 1902; 1650; 689; 1080; 629; 1351; 656; 1029; 614; 27; 1742; 605; 1133; 1042; 1366; 589; 1788; 1876; 871; 466; 23; 794; 942; 1823; 1596; 649; 171; 1767; 1683; 702; 374; 780; 1831; 1228; 1159; 1866; 748; 344; 1551; 776; 247; 166; 1800; 953; 1097; 1351; 1200; 1444; 299; 1060; 1961; 9; 61; 1487; 6; 6; 1370; 735; 585; 1949; 1564; 1626; 1440; 1994; 1074; 80; 428; 543; 858; 1445; 813; 718; 1431; 20; 1045; 430; 996; 1992; 627; 741; 853; 1385; 1637; 684; 297; 430; 1141; 174; 631; 1499; 1623; 1303; 1078; 1719; 1045; 1894; 1932; 1114; 993; 1677; 833; 730; 1425; 800; 1945; 600; 1568; 1283; 30; 1629; 1426; 179; 163; 848; 1164; 284])
17
+
18
+ let test4 _ = assert_equal 10 (countCompleteSubarrays [447; 1820; 1472; 478; 50; 1364; 1189; 1957; 431; 1982; 139; 1875; 1987; 632; 1753; 1991; 1089; 214; 1947; 848; 737; 1149; 187; 1512; 1977; 1254; 1193; 496; 1498; 534; 1489; 665; 257; 620; 1452; 505; 1085; 617; 1990; 1127; 265; 99; 590; 1735; 1872; 34; 509; 916; 37; 1215; 1770; 512; 1753; 1103; 1046; 876; 1641; 1443; 1186; 786; 1182; 156; 530; 1672; 1367; 1834; 553; 54; 1526; 74; 722; 416; 1856; 865; 21; 1289; 905; 537; 1584; 755; 69; 370; 617; 925; 305; 632; 1547; 1661; 374; 1504; 584; 1101; 467; 218; 1494; 1137; 1214; 1554; 593; 1893; 157; 1545; 516; 824; 26; 138; 1669; 1756; 30; 1059; 1726; 652; 1475; 864; 738; 1547; 1856; 1517; 1218; 1958; 1865; 1272; 279; 1977; 319; 893; 845; 1789; 1113; 1254; 1845; 1034; 231; 1231; 1594; 1615; 1553; 1003; 922; 1219; 253; 1466; 1542; 347; 1672; 459; 1106; 1212; 1878; 1245; 509; 148; 1552; 662; 1382; 752; 1913; 1274; 1899; 1713; 1239; 1224; 1608; 100; 1587; 1677; 444; 352; 471; 500; 1182; 1019; 1417; 1522; 1862; 52; 823; 1942; 1183; 1121; 1111; 1642; 1766; 452; 1002; 1103; 963; 647; 819; 121; 409; 251; 1227; 1268; 1411; 1056; 297; 375; 1911; 1037; 1088; 848; 1635; 488; 873; 135; 496; 585; 347; 1660; 1439; 64; 1434; 666; 225; 992; 1014; 345; 152; 291; 1954; 1780; 1127; 1426; 703; 1980; 73; 707; 419; 856; 1026; 160; 915; 750; 405; 1041; 1005; 1146; 912; 890; 141; 1329; 777; 481; 451; 1937; 1924; 1417; 929; 1952; 1983; 1708; 1478; 1857; 1927; 1959; 405; 1853; 199; 301; 428; 1954; 1433; 1034; 1258; 1914; 22; 1516; 415; 2000; 1137; 1857; 1519; 185; 1136; 1965; 1565; 585; 1327; 1223; 596; 1187; 1859; 1468; 1238; 1471; 1244; 1424; 583; 1320; 140; 516; 1261; 1369; 1167; 1773; 1110; 1069; 1558; 418; 1884; 656; 1501; 476; 1150; 1159; 1145; 196; 321; 229; 1727; 526; 1410; 545; 364; 160; 1368; 1647; 627; 1411; 969; 1647; 1999; 1169; 1076; 475; 1443; 646; 1938; 1870; 67; 1136; 260; 1068; 1710; 1350; 1033; 1015; 860; 1215; 1767; 1608; 1422; 1927; 1831; 968; 1147; 1712; 952; 948; 333; 568; 357; 1103; 1372; 899; 750; 1528; 367; 1603; 1492; 947; 800; 554; 1215; 1934; 76; 1659; 1425; 1882; 260; 731; 1487; 1077; 1097; 1996; 33; 1378; 810; 652; 1201; 614; 1110; 1375; 690; 82; 1442; 648; 1416; 1849; 240; 520; 673; 532; 1608; 1752; 161; 1552; 294; 397; 111; 1431; 1306; 467; 1166; 1466; 902; 1069; 625; 440; 1520; 671; 266; 999; 226; 1825; 1649; 1473; 1090; 1929; 259; 1401; 646; 1889; 1515; 1624; 896; 1622; 1214; 1410; 376; 1866; 418; 26; 305; 254; 1324; 174; 1277; 781; 30; 604; 1451; 539; 610; 406; 472; 52; 833; 876; 45; 1283; 1822; 1710; 1403; 295; 671; 1757; 1404; 942; 1007; 1918; 1103; 1835; 152; 1916; 1751; 824; 1393; 1448; 1579; 792; 1620; 1850; 147; 69; 1191; 378; 1394; 208; 1619; 937; 21; 1944; 1320; 1037; 757; 426; 196; 85; 1495; 1994; 1535; 12; 1338; 843; 1359; 1834; 175; 435; 759; 1778; 1358; 1250; 1389; 1894; 1006; 522; 1605; 1161; 1745; 945; 1366; 1114; 1234; 54; 938; 1406; 143; 1889; 300; 141; 1289; 959; 1293; 330; 1757; 1039; 1417; 971; 360; 1728; 488; 1688; 544; 1497; 1818; 1410; 462; 215; 515; 1641; 103; 114; 1669; 291; 546; 1672; 937; 797; 1816; 1474; 318; 1451; 1592; 1417; 561; 904; 671; 291; 542; 896; 1820; 975; 1919; 1971; 360; 1026; 184; 1799; 459; 1218; 1423; 1019; 468; 725; 752; 1466; 102; 1617; 968; 1763; 1456; 1990; 1050; 1840; 630; 957; 594; 307; 267; 55; 1339; 1724; 1971; 275; 603; 1413; 665; 887; 301; 979; 469; 1503; 833; 1819; 1332; 1254; 284; 1452; 1920; 1362; 1937; 1586; 325; 890; 1385; 525; 378; 429; 1927; 325; 1176; 1823; 779; 1350; 657; 1695; 1393; 598; 842; 1088; 1283; 1938; 1860; 687; 614; 264; 778; 269; 1587; 1933; 1494; 1117; 1372; 1836; 1359; 1399; 1947; 1330; 587; 812; 893; 1316; 101; 1090; 1383; 1283; 1128; 118; 1520; 146; 1186; 552; 264; 182; 1736; 329; 835; 1676; 1143; 112; 1497; 494; 1781; 688; 1917; 207; 392; 241; 1139; 1135; 1123; 1477; 511; 1094; 462; 75; 1285; 1174; 1769; 1317; 965; 749; 526; 455; 1630; 19; 754; 1089; 1730; 842; 1946; 1873; 1740; 45; 878; 1223; 479; 1274; 1278; 706; 1581; 1284; 1390; 1955; 122; 1108; 505; 1706; 236; 820; 921; 1954; 572; 1179; 1911; 162; 864; 1087; 1372; 1839; 1972; 1653; 1606; 625; 85; 1070; 889; 37; 411; 1088; 1187; 84; 270; 1867; 1123; 911; 1145; 659; 1276; 1729; 575; 475; 1663; 794; 322; 1142; 737; 917; 1888; 448; 165; 1885; 1801; 390; 738; 1703; 1245; 1569; 1819; 1568; 1163; 377; 1497; 1703; 1657; 946; 1966; 112; 1046; 161; 1339; 941; 1215; 1506; 1013; 272; 764; 355; 233; 631; 1711; 1430; 1361; 1594; 1182; 200; 1735; 484; 250; 580; 417; 1359; 1837; 1380; 983; 1785; 845; 75; 1967; 349; 753; 1437; 142; 536; 143; 11; 1654; 919; 1455; 1178; 204; 1569; 907; 1445; 963; 492; 1215; 1571; 368; 1023])
19
+
20
+ let test5 _ = assert_equal 10 (countCompleteSubarrays [737; 1335; 1825; 421; 1572; 417; 1369; 1940; 1590; 1688; 466; 1002; 1851; 1251; 413; 1771; 1878; 1353; 1994; 278; 1471; 1299; 968; 151; 143; 1471; 1433; 105; 1993; 1425; 777; 1220; 1922; 934; 1844; 1526; 1422; 1774; 1310; 1412; 1475; 319; 1214; 1812; 960; 1607; 1153; 961; 1566; 843; 495; 448; 577; 1668; 1207; 112; 1581; 1369; 764; 727; 1174; 1478; 1953; 821; 721; 1912; 185; 1686; 1349; 911; 1797; 977; 1601; 1700; 567; 925; 177; 1325; 1081; 324; 908; 673; 29; 1481; 400; 294; 813; 574; 651; 629; 779; 1076; 839; 1410; 116; 1112; 1124; 1600; 1296; 1442; 1269; 1652; 1158; 1480; 73; 1371; 671; 779; 951; 97; 798; 1825; 1317; 182; 1166; 962; 1425; 291; 1858; 557; 1974; 1586; 1924; 207; 948; 1684; 40; 1418; 485; 269; 1920; 1585; 1172; 594; 113; 131; 1807; 752; 102; 1304; 1849; 1038; 745; 365; 1667; 1342; 487; 1985; 1813; 471; 1993; 998; 1321; 607; 133; 356; 802; 1722; 1607; 242; 1901; 82; 1056; 1952; 1310; 1960; 1978; 1038; 1938; 339; 1838; 690; 1584; 1559; 1135; 1832; 1311; 474; 860; 1697; 468; 155; 1337; 596; 428; 390; 1754; 663; 615; 79; 1688; 1463; 1675; 342; 913; 281; 1745; 1301; 1535; 129; 1550; 1808; 512; 1487; 1740; 1849; 757; 1524; 449; 652; 529; 757; 1609; 276; 1289; 1499; 954; 176; 1265; 1844; 1745; 62; 911; 1183; 1873; 1791; 253; 227; 943; 586; 887; 647; 876; 1123; 1056; 37; 1775; 632; 1226; 667; 1882; 1464; 1797; 900; 1472; 1991; 399; 1333; 680; 806; 1362; 977; 1848; 482; 1218; 1317; 1396; 450; 1083; 427; 1227; 184; 41; 1201; 1903; 1882; 25; 371; 1333; 1119; 1833; 944; 1859])
21
+
22
+ let test6 _ = assert_equal 10 (countCompleteSubarrays [808; 1892; 621; 1143; 1217; 1802; 1825; 927; 158; 739; 1135; 642; 1564; 1865; 1027; 1256; 1208; 458; 733; 1309; 1642; 1885; 35; 1901; 448; 1492; 146; 49; 910; 988; 580; 1927; 1074; 354; 1990; 439; 963; 1605; 1581; 1102; 559; 20; 1576; 1528; 651; 1734; 1796; 1864; 1358; 441; 232; 1522; 1451; 1519; 644; 734; 1342; 405; 1955; 1555; 1010; 1251; 1319; 747; 1079; 1779; 1394; 1056; 396; 704; 1519; 35; 1174; 1987; 126; 603; 313; 1550; 680; 1579; 788; 47; 336; 1448; 474; 1488; 388; 1487; 1923; 895; 1547; 865; 523; 1298; 1945; 1123; 1334; 1233; 1196; 897; 1109; 1505; 910; 820; 235; 1866; 642; 685; 1795; 1541; 1670; 1615; 202; 1560; 364; 1081; 1156; 1791; 815; 1078; 698; 1072; 1739; 1918; 1180; 1212; 1227; 1496; 1267; 1668; 1559; 1861; 1803; 386; 1655; 1653; 1626; 1336; 30; 1118; 301; 695; 1161; 1657; 1001; 128; 1329; 1010; 46; 80; 1176; 1785; 79; 1704; 537; 995; 346; 1419; 1782; 1819; 378; 1046; 754; 296; 624; 1376; 1373; 1064; 1117; 380; 25; 568; 1925; 766; 1494; 1160; 948; 1071; 374; 975; 1398; 1830; 529; 525; 972; 1291; 1128; 1749; 1432; 158; 1761; 820; 1149; 44; 1132; 1498; 1586; 801; 521; 1723; 219; 936; 966; 1920; 1399; 587; 480; 264; 396; 1397; 232; 666; 4; 386; 98; 202; 1427; 1576; 561; 596; 208; 1457; 246; 864; 993; 891; 215; 1028; 473; 1577; 1412; 417; 726; 597; 498; 987; 1211; 1472; 1545; 1201; 1339; 1899; 921; 584; 989; 332; 1329; 1005; 314; 473; 1316; 868; 1933; 707; 1118; 1993; 1626; 1806; 127; 643; 1857; 1292; 1140; 279; 1079; 1443; 529; 1870; 45; 969; 1666; 377; 542; 218; 174; 787; 1620; 1290; 187; 740; 947; 387; 1800; 1535; 119; 399; 993; 1846; 1291; 861; 60; 1534; 1519; 457; 1427; 1582; 1149; 984; 144; 613; 1982; 1723; 408; 245; 1411; 568; 606; 1680; 1530; 959; 688; 970; 922; 658; 1287; 1063; 1615; 1797; 1357; 821; 408; 1126; 1277; 616; 1652; 1024; 115; 1924; 1682; 561; 206; 1690; 1825; 240; 141; 849; 522; 1842; 1055; 121; 273; 795; 1007; 292; 373; 682; 1287; 749; 889; 319; 171; 1382; 1690; 927; 1172; 1277; 947; 1698; 1076; 1075; 522; 1621; 144; 472; 538; 735; 831; 226; 284; 1450; 1853; 139; 1174; 1154; 1785; 1509; 771; 390; 847; 110; 623; 560; 1615; 1334; 1903; 1631; 374; 1377; 389; 281; 229; 548; 1105; 630; 1583; 49; 1311; 1794; 783; 665; 256; 137; 1737; 748; 315; 952; 1333; 796; 1110; 371; 1651; 1812; 1884; 489; 387; 1900; 1648; 884; 1676; 1097; 1567; 949; 737; 1743; 548; 324; 251; 1693; 41; 663; 1039; 1507; 1754; 1351; 905; 915; 1750; 741; 1076; 1938; 460; 1183; 729; 1987; 987; 1055; 481; 795; 603; 1199; 19; 1719; 311; 86; 1501; 1434; 618; 1876; 1990; 742; 1894; 1129; 1197; 123; 800; 1935; 222; 1091; 1950; 953; 1908; 130; 658; 652; 478; 1745; 1677; 1651; 33; 1027; 1493; 253; 1925; 1523; 489; 1098; 1066; 128; 999; 1852; 178; 1850; 985; 1662; 338; 1078; 251; 1945; 894; 1637; 1446; 1738; 327; 401; 1149; 1556; 523; 1971; 1341; 2000; 196; 161; 1688; 1942; 3; 1371; 1403; 601; 1300; 1855; 812; 549; 938; 87; 1473; 1084; 868; 1171; 242; 1335; 1521; 1193; 1920; 1951; 1948; 1926; 484; 751; 1253; 1813; 296; 910; 192; 1002; 1467; 1548; 1652; 933; 270; 1719; 612; 1243; 1425; 1961; 226; 2; 1639; 1856; 37; 1072; 1438; 1428; 1557; 1679; 963; 1343; 830; 1818; 1027; 792; 1123; 1444; 191; 358; 988; 1367; 833])
23
+
24
+ let test7 _ = assert_equal 10 (countCompleteSubarrays [1490; 1499; 1262; 1043; 937; 1062; 550; 1579; 866; 1878; 902; 642; 1501; 1325; 896; 520; 736; 1502; 1405; 577; 1075; 778; 1308; 961; 1744; 1583; 504; 1861; 453; 1060; 1656; 1689; 159; 1865; 568; 353; 806; 206; 380])
25
+
26
+
27
+ (* Grouping test cases *)
28
+ let suite = "Test Suite for countCompleteSubarrays" >::: [
29
+
30
+ "test1" >:: test1;
31
+ "test2" >:: test2;
32
+ "test3" >:: test3;
33
+ "test4" >:: test4;
34
+ "test5" >:: test5;
35
+ "test6" >:: test6;
36
+ "test7" >:: test7;
37
+ ]
38
+
39
+
40
+ (* Running the tests *)
41
+ let () = run_test_tt_main suite
42
+ end
count_complete_subarrays_in_an_array/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.countCompleteSubarrays(List(1,3,1,2,2)), 4)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.countCompleteSubarrays(List(5,5,5,5)), 10)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.countCompleteSubarrays(985,684,1562,107,515,123,1924,1501,1874,557,1773,800,123,827,547,1285,357,194,227,396,192,751,72,918,1496,1174,1325,1478,821,799,164,477,1859,1431,302,1636,1061,612,211,482,1891,898,378,1371,1454,1034,1216,1370,1014,1224,1148,1453,1613,204,270,1502,1472,1336,1238,966,1761,424,642,1589,316,71,507,241,1810,379,1680,1772,1283,1521,1631,465,578,83,1762,1435,1743,910,725,1707,831,571,249,241,504,150,1239,895,1084,345,1593,1420,969,640,171,1511,1146,918,579,1756,753,289,6,880,777,1513,1384,1928,895,854,1642,1498,830,533,1050,1045,650,1031,1729,381,209,1528,1096,941,599,931,401,1011,1742,584,126,134,1224,437,711,451,1954,1305,1279,1222,1486,1362,1618,1924,86,1928,1401,1089,45,1028,903,1626,1544,243,917,1274,1475,382,1221,550,1484,229,108,50,1621,1229,1158,1633,1747,1921,1309,418,1147,452,1944,766,1006,283,159,144,1184,1764,980,936,450,371,103,1735,2,857,1035,1809,181,1887,997,349,1384,1086,279,929,1777,1335,607,197,221,404,1994,738,176,1159,1672,1303,536,14,1524,1574,259,386,758,352,429,152,894,1269,1814,1957,964,1193,1938,2000,398,705,828,1420,1328,312,1892,110,1572,20,649,1156,891,979,1337,179,760,1712,847,407,518,553,804,708,1914,871,453,622,987,1370,55,710,294,827,1872,106,91,1695,633,301,877,64,1759,659,515,1519,328,535,917,1384,607,278,512,676,480,283,1592,965,1490,915,194,965,1636,86,33,1734,317,1226,1802,872,983,1220,1016,1963,484,1252,724,1291,1189,971,239,1002,412,109,407,1898,743,1048,1367,1106,18,1520,1837,1305,51,268,1602,1992,1022,1649,1340,1980,1893,1913,524,68,1534,290,440,183,177,587,1553,1186,861,405,1355,1386,1078,1564,43,1647,1490,1640,856,1510,1949,88,739,331,89,398,1298,1014,970,581,1270,241,1540,547,826,818,1744,555,1383,1299,813,1011,550,1295,17,1375,712,1679,1793,1774,151,1651,1510,192,1929,632,1500,992,742,1497,463,201,1847,1027,1409,1976,1267,402,1995,1438,1397,1975,1938,1826,67,1003,1710,752,1996,516,1142,1329,913,1332,824,1316,223,1020,1610,1792,60,332,241,1780,1116,423,1144,1849,1305,597,112,1224,1332,1207,1515,403,160,457,1301,698,1983,1558,1284,636,437,820,1082,1559,1958,1599,1583,1357,1393,1267,675,1378,35,1751,1493,105,477,1779,1512,1613,460,548,16,1085,1142,332,161,1086,288,1230,1001,419,403,356,552,877,1915,657,699,1089,1093,178,1356,1935,1835,1804,179,578,658,1784,72,1696,841,1063,1074,341,625,925,240,154,1974,1094,1841,1987,334,1676,1844,1302,1252,591,1412,518,655,360,1753,982,240,866,629,1084,1654,850,570,356,1320,1201,924,1809,378,107,1907,441,1677,1219,256,1033,1589,441,95,631,1807,1714,994,933,1901,111,216,1982,1848,465,1338,953,124,1245,1811,1281,1403,462,1343,728,901,132,1311,1570,136,1902,1650,689,1080,629,1351,656,1029,614,27,1742,605,1133,1042,1366,589,1788,1876,871,466,23,794,942,1823,1596,649,171,1767,1683,702,374,780,1831,1228,1159,1866,748,344,1551,776,247,166,1800,953,1097,1351,1200,1444,299,1060,1961,9,61,1487,6,6,1370,735,585,1949,1564,1626,1440,1994,1074,80,428,543,858,1445,813,718,1431,20,1045,430,996,1992,627,741,853,1385,1637,684,297,430,1141,174,631,1499,1623,1303,1078,1719,1045,1894,1932,1114,993,1677,833,730,1425,800,1945,600,1568,1283,30,1629,1426,179,163,848,1164,284), 1)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.countCompleteSubarrays(447,1820,1472,478,50,1364,1189,1957,431,1982,139,1875,1987,632,1753,1991,1089,214,1947,848,737,1149,187,1512,1977,1254,1193,496,1498,534,1489,665,257,620,1452,505,1085,617,1990,1127,265,99,590,1735,1872,34,509,916,37,1215,1770,512,1753,1103,1046,876,1641,1443,1186,786,1182,156,530,1672,1367,1834,553,54,1526,74,722,416,1856,865,21,1289,905,537,1584,755,69,370,617,925,305,632,1547,1661,374,1504,584,1101,467,218,1494,1137,1214,1554,593,1893,157,1545,516,824,26,138,1669,1756,30,1059,1726,652,1475,864,738,1547,1856,1517,1218,1958,1865,1272,279,1977,319,893,845,1789,1113,1254,1845,1034,231,1231,1594,1615,1553,1003,922,1219,253,1466,1542,347,1672,459,1106,1212,1878,1245,509,148,1552,662,1382,752,1913,1274,1899,1713,1239,1224,1608,100,1587,1677,444,352,471,500,1182,1019,1417,1522,1862,52,823,1942,1183,1121,1111,1642,1766,452,1002,1103,963,647,819,121,409,251,1227,1268,1411,1056,297,375,1911,1037,1088,848,1635,488,873,135,496,585,347,1660,1439,64,1434,666,225,992,1014,345,152,291,1954,1780,1127,1426,703,1980,73,707,419,856,1026,160,915,750,405,1041,1005,1146,912,890,141,1329,777,481,451,1937,1924,1417,929,1952,1983,1708,1478,1857,1927,1959,405,1853,199,301,428,1954,1433,1034,1258,1914,22,1516,415,2000,1137,1857,1519,185,1136,1965,1565,585,1327,1223,596,1187,1859,1468,1238,1471,1244,1424,583,1320,140,516,1261,1369,1167,1773,1110,1069,1558,418,1884,656,1501,476,1150,1159,1145,196,321,229,1727,526,1410,545,364,160,1368,1647,627,1411,969,1647,1999,1169,1076,475,1443,646,1938,1870,67,1136,260,1068,1710,1350,1033,1015,860,1215,1767,1608,1422,1927,1831,968,1147,1712,952,948,333,568,357,1103,1372,899,750,1528,367,1603,1492,947,800,554,1215,1934,76,1659,1425,1882,260,731,1487,1077,1097,1996,33,1378,810,652,1201,614,1110,1375,690,82,1442,648,1416,1849,240,520,673,532,1608,1752,161,1552,294,397,111,1431,1306,467,1166,1466,902,1069,625,440,1520,671,266,999,226,1825,1649,1473,1090,1929,259,1401,646,1889,1515,1624,896,1622,1214,1410,376,1866,418,26,305,254,1324,174,1277,781,30,604,1451,539,610,406,472,52,833,876,45,1283,1822,1710,1403,295,671,1757,1404,942,1007,1918,1103,1835,152,1916,1751,824,1393,1448,1579,792,1620,1850,147,69,1191,378,1394,208,1619,937,21,1944,1320,1037,757,426,196,85,1495,1994,1535,12,1338,843,1359,1834,175,435,759,1778,1358,1250,1389,1894,1006,522,1605,1161,1745,945,1366,1114,1234,54,938,1406,143,1889,300,141,1289,959,1293,330,1757,1039,1417,971,360,1728,488,1688,544,1497,1818,1410,462,215,515,1641,103,114,1669,291,546,1672,937,797,1816,1474,318,1451,1592,1417,561,904,671,291,542,896,1820,975,1919,1971,360,1026,184,1799,459,1218,1423,1019,468,725,752,1466,102,1617,968,1763,1456,1990,1050,1840,630,957,594,307,267,55,1339,1724,1971,275,603,1413,665,887,301,979,469,1503,833,1819,1332,1254,284,1452,1920,1362,1937,1586,325,890,1385,525,378,429,1927,325,1176,1823,779,1350,657,1695,1393,598,842,1088,1283,1938,1860,687,614,264,778,269,1587,1933,1494,1117,1372,1836,1359,1399,1947,1330,587,812,893,1316,101,1090,1383,1283,1128,118,1520,146,1186,552,264,182,1736,329,835,1676,1143,112,1497,494,1781,688,1917,207,392,241,1139,1135,1123,1477,511,1094,462,75,1285,1174,1769,1317,965,749,526,455,1630,19,754,1089,1730,842,1946,1873,1740,45,878,1223,479,1274,1278,706,1581,1284,1390,1955,122,1108,505,1706,236,820,921,1954,572,1179,1911,162,864,1087,1372,1839,1972,1653,1606,625,85,1070,889,37,411,1088,1187,84,270,1867,1123,911,1145,659,1276,1729,575,475,1663,794,322,1142,737,917,1888,448,165,1885,1801,390,738,1703,1245,1569,1819,1568,1163,377,1497,1703,1657,946,1966,112,1046,161,1339,941,1215,1506,1013,272,764,355,233,631,1711,1430,1361,1594,1182,200,1735,484,250,580,417,1359,1837,1380,983,1785,845,75,1967,349,753,1437,142,536,143,11,1654,919,1455,1178,204,1569,907,1445,963,492,1215,1571,368,1023), 1)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.countCompleteSubarrays(737,1335,1825,421,1572,417,1369,1940,1590,1688,466,1002,1851,1251,413,1771,1878,1353,1994,278,1471,1299,968,151,143,1471,1433,105,1993,1425,777,1220,1922,934,1844,1526,1422,1774,1310,1412,1475,319,1214,1812,960,1607,1153,961,1566,843,495,448,577,1668,1207,112,1581,1369,764,727,1174,1478,1953,821,721,1912,185,1686,1349,911,1797,977,1601,1700,567,925,177,1325,1081,324,908,673,29,1481,400,294,813,574,651,629,779,1076,839,1410,116,1112,1124,1600,1296,1442,1269,1652,1158,1480,73,1371,671,779,951,97,798,1825,1317,182,1166,962,1425,291,1858,557,1974,1586,1924,207,948,1684,40,1418,485,269,1920,1585,1172,594,113,131,1807,752,102,1304,1849,1038,745,365,1667,1342,487,1985,1813,471,1993,998,1321,607,133,356,802,1722,1607,242,1901,82,1056,1952,1310,1960,1978,1038,1938,339,1838,690,1584,1559,1135,1832,1311,474,860,1697,468,155,1337,596,428,390,1754,663,615,79,1688,1463,1675,342,913,281,1745,1301,1535,129,1550,1808,512,1487,1740,1849,757,1524,449,652,529,757,1609,276,1289,1499,954,176,1265,1844,1745,62,911,1183,1873,1791,253,227,943,586,887,647,876,1123,1056,37,1775,632,1226,667,1882,1464,1797,900,1472,1991,399,1333,680,806,1362,977,1848,482,1218,1317,1396,450,1083,427,1227,184,41,1201,1903,1882,25,371,1333,1119,1833,944,1859), 1)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.countCompleteSubarrays(808,1892,621,1143,1217,1802,1825,927,158,739,1135,642,1564,1865,1027,1256,1208,458,733,1309,1642,1885,35,1901,448,1492,146,49,910,988,580,1927,1074,354,1990,439,963,1605,1581,1102,559,20,1576,1528,651,1734,1796,1864,1358,441,232,1522,1451,1519,644,734,1342,405,1955,1555,1010,1251,1319,747,1079,1779,1394,1056,396,704,1519,35,1174,1987,126,603,313,1550,680,1579,788,47,336,1448,474,1488,388,1487,1923,895,1547,865,523,1298,1945,1123,1334,1233,1196,897,1109,1505,910,820,235,1866,642,685,1795,1541,1670,1615,202,1560,364,1081,1156,1791,815,1078,698,1072,1739,1918,1180,1212,1227,1496,1267,1668,1559,1861,1803,386,1655,1653,1626,1336,30,1118,301,695,1161,1657,1001,128,1329,1010,46,80,1176,1785,79,1704,537,995,346,1419,1782,1819,378,1046,754,296,624,1376,1373,1064,1117,380,25,568,1925,766,1494,1160,948,1071,374,975,1398,1830,529,525,972,1291,1128,1749,1432,158,1761,820,1149,44,1132,1498,1586,801,521,1723,219,936,966,1920,1399,587,480,264,396,1397,232,666,4,386,98,202,1427,1576,561,596,208,1457,246,864,993,891,215,1028,473,1577,1412,417,726,597,498,987,1211,1472,1545,1201,1339,1899,921,584,989,332,1329,1005,314,473,1316,868,1933,707,1118,1993,1626,1806,127,643,1857,1292,1140,279,1079,1443,529,1870,45,969,1666,377,542,218,174,787,1620,1290,187,740,947,387,1800,1535,119,399,993,1846,1291,861,60,1534,1519,457,1427,1582,1149,984,144,613,1982,1723,408,245,1411,568,606,1680,1530,959,688,970,922,658,1287,1063,1615,1797,1357,821,408,1126,1277,616,1652,1024,115,1924,1682,561,206,1690,1825,240,141,849,522,1842,1055,121,273,795,1007,292,373,682,1287,749,889,319,171,1382,1690,927,1172,1277,947,1698,1076,1075,522,1621,144,472,538,735,831,226,284,1450,1853,139,1174,1154,1785,1509,771,390,847,110,623,560,1615,1334,1903,1631,374,1377,389,281,229,548,1105,630,1583,49,1311,1794,783,665,256,137,1737,748,315,952,1333,796,1110,371,1651,1812,1884,489,387,1900,1648,884,1676,1097,1567,949,737,1743,548,324,251,1693,41,663,1039,1507,1754,1351,905,915,1750,741,1076,1938,460,1183,729,1987,987,1055,481,795,603,1199,19,1719,311,86,1501,1434,618,1876,1990,742,1894,1129,1197,123,800,1935,222,1091,1950,953,1908,130,658,652,478,1745,1677,1651,33,1027,1493,253,1925,1523,489,1098,1066,128,999,1852,178,1850,985,1662,338,1078,251,1945,894,1637,1446,1738,327,401,1149,1556,523,1971,1341,2000,196,161,1688,1942,3,1371,1403,601,1300,1855,812,549,938,87,1473,1084,868,1171,242,1335,1521,1193,1920,1951,1948,1926,484,751,1253,1813,296,910,192,1002,1467,1548,1652,933,270,1719,612,1243,1425,1961,226,2,1639,1856,37,1072,1438,1428,1557,1679,963,1343,830,1818,1027,792,1123,1444,191,358,988,1367,833), 1)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.countCompleteSubarrays(1490,1499,1262,1043,937,1062,550,1579,866,1878,902,642,1501,1325,896,520,736,1502,1405,577,1075,778,1308,961,1744,1583,504,1861,453,1060,1656,1689,159,1865,568,353,806,206,380), 1)
30
+ }
31
+
32
+ }
count_complete_substrings/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
count_complete_substrings/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(3, countCompleteSubstrings("igigee", 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(6, countCompleteSubstrings("aaabbbccc", 3));
19
+ }
20
+
21
+ }
count_complete_substrings/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
count_complete_substrings/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
count_complete_substrings/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
count_connected_components_in_lcm_graph/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
count_connected_components_in_lcm_graph/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(4, countComponents(new ArrayList<>(Arrays.asList(2,4,8,3,9)), 5));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(2, countComponents(new ArrayList<>(Arrays.asList(2,4,8,3,9,12)), 10));
19
+ }
20
+
21
+ }
count_connected_components_in_lcm_graph/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a473e8a59783955060605facc366f8670a4acddfd5b474a0ae29b692ebd44a5
3
+ size 16470547
count_connected_components_in_lcm_graph/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
count_connected_components_in_lcm_graph/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
count_days_spent_together/.DS_Store ADDED
Binary file (6.15 kB). View file
 
count_days_spent_together/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (countDaysTogether \"08-15 \" \"08-18 \" \"08-16 \" \"08-19 \")," 3 (countDaysTogether "08-15" "08-18" "08-16" "08-19"))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (countDaysTogether \"10-01 \" \"10-31 \" \"11-01 \" \"12-31 \")," 0 (countDaysTogether "10-01" "10-31" "11-01" "12-31"))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
count_days_spent_together/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(3, countDaysTogether("08-15", "08-18", "08-16", "08-19"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(0, countDaysTogether("10-01", "10-31", "11-01", "12-31"));
19
+ }
20
+
21
+ }
count_days_spent_together/meta.json ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2496,
3
+ "name": "count_days_spent_together",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/count-days-spent-together/",
6
+ "date": "1662163200000",
7
+ "task_description": "Alice and Bob are traveling to Rome for separate business meetings. You are given 4 strings `arriveAlice`, `leaveAlice`, `arriveBob`, and `leaveBob`. Alice will be in the city from the dates `arriveAlice` to `leaveAlice` (**inclusive**), while Bob will be in the city from the dates `arriveBob` to `leaveBob` (**inclusive**). Each will be a 5-character string in the format `\"MM-DD\"`, corresponding to the month and day of the date. Return_ the total number of days that Alice and Bob are in Rome together._ You can assume that all dates occur in the **same** calendar year, which is **not** a leap year. Note that the number of days per month can be represented as: `[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]`. **Example 1:** ``` **Input:** arriveAlice = \"08-15\", leaveAlice = \"08-18\", arriveBob = \"08-16\", leaveBob = \"08-19\" **Output:** 3 **Explanation:** Alice will be in Rome from August 15 to August 18. Bob will be in Rome from August 16 to August 19. They are both in Rome together on August 16th, 17th, and 18th, so the answer is 3. ``` **Example 2:** ``` **Input:** arriveAlice = \"10-01\", leaveAlice = \"10-31\", arriveBob = \"11-01\", leaveBob = \"12-31\" **Output:** 0 **Explanation:** There is no day when Alice and Bob are in Rome together, so we return 0. ``` **Constraints:** All dates are provided in the format `\"MM-DD\"`. Alice and Bob's arrival dates are **earlier than or equal to** their leaving dates. The given dates are valid dates of a **non-leap** year.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "arriveAlice = \"08-15\", leaveAlice = \"08-18\", arriveBob = \"08-16\", leaveBob = \"08-19\"",
12
+ "output": "3 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "arriveAlice = \"10-01\", leaveAlice = \"10-31\", arriveBob = \"11-01\", leaveBob = \"12-31\"",
17
+ "output": "0 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ "\"10-15\"",
24
+ "\"11-29\"",
25
+ "\"10-05\"",
26
+ "\"10-15\""
27
+ ],
28
+ "output": 1
29
+ },
30
+ {
31
+ "input": [
32
+ "\"12-30\"",
33
+ "\"12-31\"",
34
+ "\"02-06\"",
35
+ "\"12-30\""
36
+ ],
37
+ "output": 1
38
+ },
39
+ {
40
+ "input": [
41
+ "\"05-29\"",
42
+ "\"07-18\"",
43
+ "\"07-18\"",
44
+ "\"10-07\""
45
+ ],
46
+ "output": 1
47
+ },
48
+ {
49
+ "input": [
50
+ "\"04-06\"",
51
+ "\"12-18\"",
52
+ "\"09-24\"",
53
+ "\"10-21\""
54
+ ],
55
+ "output": 28
56
+ },
57
+ {
58
+ "input": [
59
+ "\"04-15\"",
60
+ "\"05-22\"",
61
+ "\"05-22\"",
62
+ "\"12-31\""
63
+ ],
64
+ "output": 1
65
+ },
66
+ {
67
+ "input": [
68
+ "\"09-10\"",
69
+ "\"10-01\"",
70
+ "\"07-01\"",
71
+ "\"09-10\""
72
+ ],
73
+ "output": 1
74
+ },
75
+ {
76
+ "input": [
77
+ "\"09-08\"",
78
+ "\"12-01\"",
79
+ "\"06-25\"",
80
+ "\"11-01\""
81
+ ],
82
+ "output": 55
83
+ },
84
+ {
85
+ "input": [
86
+ "09-12",
87
+ "10-09",
88
+ "05-06",
89
+ "12-09"
90
+ ],
91
+ "output": 28
92
+ },
93
+ {
94
+ "input": [
95
+ "09-18",
96
+ "12-05",
97
+ "02-22",
98
+ "10-19"
99
+ ],
100
+ "output": 32
101
+ },
102
+ {
103
+ "input": [
104
+ "03-24",
105
+ "11-23",
106
+ "11-23",
107
+ "12-06"
108
+ ],
109
+ "output": 1
110
+ }
111
+ ],
112
+ "haskell_template": "countDaysTogether :: String -> String -> String -> String -> Int\ncountDaysTogether arriveAlice leaveAlice arriveBob leaveBob ",
113
+ "ocaml_template": "let countDaysTogether (arriveAlice: string) (leaveAlice: string) (arriveBob: string) (leaveBob: string) : int = ",
114
+ "scala_template": "def countDaysTogether(arriveAlice: String,leaveAlice: String,arriveBob: String,leaveBob: String): Int = { \n \n}",
115
+ "java_template": "public static int countDaysTogether(String arriveAlice, String leaveAlice, String arriveBob, String leaveBob) {\n\n}",
116
+ "python_template": "class Solution(object):\n def countDaysTogether(self, arriveAlice, leaveAlice, arriveBob, leaveBob):\n \"\"\"\n :type arriveAlice: str\n :type leaveAlice: str\n :type arriveBob: str\n :type leaveBob: str\n :rtype: int\n \"\"\"\n "
117
+ }
count_days_spent_together/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 3 (countDaysTogether "08-15" "08-18" "08-16" "08-19")
12
+
13
+ let test2 _ = assert_equal 0 (countDaysTogether "10-01" "10-31" "11-01" "12-31")
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for countDaysTogether" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
count_days_spent_together/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.countDaysTogether("08-15","08-18","08-16","08-19"), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.countDaysTogether("10-01","10-31","11-01","12-31"), 0)
10
+ }
11
+
12
+ }
count_days_without_meetings/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
count_days_without_meetings/java_tests/Main.java ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(2, countDays(10, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(5,7)),new ArrayList<>(Arrays.asList(1,3)),new ArrayList<>(Arrays.asList(9,10))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(1, countDays(5, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2,4)),new ArrayList<>(Arrays.asList(1,3))))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(0, countDays(6, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,6))))));
23
+ }
24
+
25
+ }
count_days_without_meetings/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53fd535f13e5099082fa5da254dbe46a70142c9cf37a426cd435d326c69e15a5
3
+ size 20862183
count_days_without_meetings/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
count_days_without_meetings/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
count_elements_with_maximum_frequency/haskell_tests/Main.hs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ maxFrequencyElements :: [Int] -> Int
7
+ maxFrequencyElements nums = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (maxFrequencyElements [1,2,2,3,1,4])," 4 (maxFrequencyElements [1,2,2,3,1,4]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (maxFrequencyElements [1,2,3,4,5])," 5 (maxFrequencyElements [1,2,3,4,5]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (maxFrequencyElements [80, 65, 89, 19, 79, 52, 54, 72, 15, 35, 85])," 11 (maxFrequencyElements [80, 65, 89, 19, 79, 52, 54, 72, 15, 35, 85]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (maxFrequencyElements [56, 59, 77, 53, 13, 70, 4, 43, 1, 40, 72, 93, 32, 42, 54, 49, 45, 47, 25, 99, 67, 81, 90, 20, 16, 20, 14, 21, 46, 49, 67, 59, 75, 33, 96, 54, 48, 30, 1, 3, 46, 17, 96, 64, 36, 18, 80, 15, 18, 55, 76, 83, 60, 64, 45, 16, 72, 10, 32, 53, 16, 31, 2, 81, 28, 33, 1, 72, 60, 49, 98, 67, 82, 1, 41, 44, 60, 59])," 4 (maxFrequencyElements [56, 59, 77, 53, 13, 70, 4, 43, 1, 40, 72, 93, 32, 42, 54, 49, 45, 47, 25, 99, 67, 81, 90, 20, 16, 20, 14, 21, 46, 49, 67, 59, 75, 33, 96, 54, 48, 30, 1, 3, 46, 17, 96, 64, 36, 18, 80, 15, 18, 55, 76, 83, 60, 64, 45, 16, 72, 10, 32, 53, 16, 31, 2, 81, 28, 33, 1, 72, 60, 49, 98, 67, 82, 1, 41, 44, 60, 59]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (maxFrequencyElements [47, 33, 54, 38, 41, 9, 90, 84, 80, 66])," 10 (maxFrequencyElements [47, 33, 54, 38, 41, 9, 90, 84, 80, 66]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (maxFrequencyElements [95, 49, 59, 77, 35])," 5 (maxFrequencyElements [95, 49, 59, 77, 35]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (maxFrequencyElements [5, 85, 82, 86, 45, 66, 82, 28])," 2 (maxFrequencyElements [5, 85, 82, 86, 45, 66, 82, 28]))
33
+
34
+
35
+ -- Grouping test cases
36
+ tests :: Test
37
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6]
38
+
39
+ -- Running the tests
40
+ main :: IO Counts
41
+ main = runTestTT tests
count_elements_with_maximum_frequency/java_tests/Main.java ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(4, maxFrequencyElements(Arrays.asList(1,2,2,3,1,4)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(5, maxFrequencyElements(Arrays.asList(1,2,3,4,5)));
18
+ }
19
+
20
+ }
count_elements_with_maximum_frequency/meta.json ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3242,
3
+ "name": "count_elements_with_maximum_frequency",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/count-elements-with-maximum-frequency/",
6
+ "date": "2024-01-07 00:00:00",
7
+ "task_description": "You are given an array `nums` consisting of **positive** integers. Return _the **total frequencies** of elements in__ _`nums` _such that those elements all have the **maximum** frequency_. The **frequency** of an element is the number of occurrences of that element in the array. **Example 1:** ``` **Input:** nums = [1,2,2,3,1,4] **Output:** 4 **Explanation:** The elements 1 and 2 have a frequency of 2 which is the maximum frequency in the array. So the number of elements in the array with maximum frequency is 4. ``` **Example 2:** ``` **Input:** nums = [1,2,3,4,5] **Output:** 5 **Explanation:** All elements of the array have a frequency of 1 which is the maximum. So the number of elements in the array with maximum frequency is 5. ``` **Constraints:** `1 <= nums.length <= 100` `1 <= nums[i] <= 100`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [1,2,2,3,1,4]",
12
+ "output": "4 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [1,2,3,4,5]",
17
+ "output": "5 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 80,
24
+ 65,
25
+ 89,
26
+ 19,
27
+ 79,
28
+ 52,
29
+ 54,
30
+ 72,
31
+ 15,
32
+ 35,
33
+ 85
34
+ ],
35
+ "output": 11
36
+ },
37
+ {
38
+ "input": [
39
+ 56,
40
+ 59,
41
+ 77,
42
+ 53,
43
+ 13,
44
+ 70,
45
+ 4,
46
+ 43,
47
+ 1,
48
+ 40,
49
+ 72,
50
+ 93,
51
+ 32,
52
+ 42,
53
+ 54,
54
+ 49,
55
+ 45,
56
+ 47,
57
+ 25,
58
+ 99,
59
+ 67,
60
+ 81,
61
+ 90,
62
+ 20,
63
+ 16,
64
+ 20,
65
+ 14,
66
+ 21,
67
+ 46,
68
+ 49,
69
+ 67,
70
+ 59,
71
+ 75,
72
+ 33,
73
+ 96,
74
+ 54,
75
+ 48,
76
+ 30,
77
+ 1,
78
+ 3,
79
+ 46,
80
+ 17,
81
+ 96,
82
+ 64,
83
+ 36,
84
+ 18,
85
+ 80,
86
+ 15,
87
+ 18,
88
+ 55,
89
+ 76,
90
+ 83,
91
+ 60,
92
+ 64,
93
+ 45,
94
+ 16,
95
+ 72,
96
+ 10,
97
+ 32,
98
+ 53,
99
+ 16,
100
+ 31,
101
+ 2,
102
+ 81,
103
+ 28,
104
+ 33,
105
+ 1,
106
+ 72,
107
+ 60,
108
+ 49,
109
+ 98,
110
+ 67,
111
+ 82,
112
+ 1,
113
+ 41,
114
+ 44,
115
+ 60,
116
+ 59
117
+ ],
118
+ "output": 4
119
+ },
120
+ {
121
+ "input": [
122
+ 47,
123
+ 33,
124
+ 54,
125
+ 38,
126
+ 41,
127
+ 9,
128
+ 90,
129
+ 84,
130
+ 80,
131
+ 66
132
+ ],
133
+ "output": 10
134
+ },
135
+ {
136
+ "input": [
137
+ 95,
138
+ 49,
139
+ 59,
140
+ 77,
141
+ 35
142
+ ],
143
+ "output": 5
144
+ },
145
+ {
146
+ "input": [
147
+ 5,
148
+ 85,
149
+ 82,
150
+ 86,
151
+ 45,
152
+ 66,
153
+ 82,
154
+ 28
155
+ ],
156
+ "output": 2
157
+ }
158
+ ],
159
+ "haskell_template": "maxFrequencyElements :: [Int] -> Int\nmaxFrequencyElements nums ",
160
+ "ocaml_template": "let maxFrequencyElements (nums: int list) : int = ",
161
+ "scala_template": "def maxFrequencyElements(nums: List[Int]): Int = { \n \n}",
162
+ "java_template": "class Solution {\n public int maxFrequencyElements(int[] nums) {\n \n }\n}",
163
+ "python_template": "class Solution(object):\n def maxFrequencyElements(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
164
+ }
count_elements_with_maximum_frequency/ocaml_tests/main.ml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let maxFrequencyElements (nums: int list) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 4 (maxFrequencyElements [1;2;2;3;1;4])
13
+
14
+ let test2 _ = assert_equal 5 (maxFrequencyElements [1;2;3;4;5])
15
+
16
+ let test3 _ = assert_equal 5 (maxFrequencyElements [80; 65; 89; 19; 79; 52; 54; 72; 15; 35; 85])
17
+
18
+ let test4 _ = assert_equal 5 (maxFrequencyElements [56; 59; 77; 53; 13; 70; 4; 43; 1; 40; 72; 93; 32; 42; 54; 49; 45; 47; 25; 99; 67; 81; 90; 20; 16; 20; 14; 21; 46; 49; 67; 59; 75; 33; 96; 54; 48; 30; 1; 3; 46; 17; 96; 64; 36; 18; 80; 15; 18; 55; 76; 83; 60; 64; 45; 16; 72; 10; 32; 53; 16; 31; 2; 81; 28; 33; 1; 72; 60; 49; 98; 67; 82; 1; 41; 44; 60; 59])
19
+
20
+ let test5 _ = assert_equal 5 (maxFrequencyElements [47; 33; 54; 38; 41; 9; 90; 84; 80; 66])
21
+
22
+ let test6 _ = assert_equal 5 (maxFrequencyElements [95; 49; 59; 77; 35])
23
+
24
+ let test7 _ = assert_equal 5 (maxFrequencyElements [5; 85; 82; 86; 45; 66; 82; 28])
25
+
26
+
27
+ (* Grouping test cases *)
28
+ let suite = "Test Suite for maxFrequencyElements" >::: [
29
+
30
+ "test1" >:: test1;
31
+ "test2" >:: test2;
32
+ "test3" >:: test3;
33
+ "test4" >:: test4;
34
+ "test5" >:: test5;
35
+ "test6" >:: test6;
36
+ "test7" >:: test7;
37
+ ]
38
+
39
+
40
+ (* Running the tests *)
41
+ let () = run_test_tt_main suite
42
+ end
count_elements_with_maximum_frequency/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maxFrequencyElements(List(1,2,2,3,1,4)), 4)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maxFrequencyElements(List(1,2,3,4,5)), 5)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.maxFrequencyElements(80,65,89,19,79,52,54,72,15,35,85), 11)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.maxFrequencyElements(56,59,77,53,13,70,4,43,1,40,72,93,32,42,54,49,45,47,25,99,67,81,90,20,16,20,14,21,46,49,67,59,75,33,96,54,48,30,1,3,46,17,96,64,36,18,80,15,18,55,76,83,60,64,45,16,72,10,32,53,16,31,2,81,28,33,1,72,60,49,98,67,82,1,41,44,60,59), 4)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.maxFrequencyElements(47,33,54,38,41,9,90,84,80,66), 10)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.maxFrequencyElements(95,49,59,77,35), 5)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.maxFrequencyElements(5,85,82,86,45,66,82,28), 2)
30
+ }
31
+
32
+ }
count_elements_with_strictly_smaller_and_greater_elements/.DS_Store ADDED
Binary file (6.15 kB). View file
 
count_elements_with_strictly_smaller_and_greater_elements/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (countElements [11,7,2,15])," 2 (countElements [11,7,2,15]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (countElements [-3,3,3,90])," 2 (countElements [-3,3,3,90]))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
count_elements_with_strictly_smaller_and_greater_elements/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(2, countElements(new ArrayList<>(Arrays.asList(11,7,2,15))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(2, countElements(new ArrayList<>(Arrays.asList(-3,3,3,90))));
19
+ }
20
+
21
+ }
count_elements_with_strictly_smaller_and_greater_elements/meta.json ADDED
@@ -0,0 +1,501 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2269,
3
+ "name": "count_elements_with_strictly_smaller_and_greater_elements",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements/",
6
+ "date": "1642291200000",
7
+ "task_description": "Given an integer array `nums`, return _the number of elements that have **both** a strictly smaller and a strictly greater element appear in _`nums`. **Example 1:** ``` **Input:** nums = [11,7,2,15] **Output:** 2 **Explanation:** The element 7 has the element 2 strictly smaller than it and the element 11 strictly greater than it. Element 11 has element 7 strictly smaller than it and element 15 strictly greater than it. In total there are 2 elements having both a strictly smaller and a strictly greater element appear in `nums`. ``` **Example 2:** ``` **Input:** nums = [-3,3,3,90] **Output:** 2 **Explanation:** The element 3 has the element -3 strictly smaller than it and the element 90 strictly greater than it. Since there are two elements with the value 3, in total there are 2 elements having both a strictly smaller and a strictly greater element appear in `nums`. ``` **Constraints:** `1 <= nums.length <= 100` `-105 <= nums[i] <= 105`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [11,7,2,15]",
12
+ "output": "2 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [-3,3,3,90]",
17
+ "output": "2 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ -16495,
24
+ -75944,
25
+ -48832,
26
+ -43211,
27
+ 55199,
28
+ -26971,
29
+ 56250,
30
+ 36003,
31
+ 38879,
32
+ -74791,
33
+ -94268,
34
+ 58607,
35
+ 16273,
36
+ 55472,
37
+ -56805,
38
+ -95926,
39
+ -11111,
40
+ -52242,
41
+ -88431,
42
+ 64772,
43
+ 21060,
44
+ 69992,
45
+ 71683,
46
+ -24063,
47
+ -90117,
48
+ -75520,
49
+ -69648,
50
+ -42323,
51
+ -73811,
52
+ -62509,
53
+ 98238,
54
+ 24283,
55
+ 84870,
56
+ 6862,
57
+ 17398,
58
+ -7013,
59
+ -75609,
60
+ 45147,
61
+ 31890,
62
+ -41994,
63
+ -48075,
64
+ -74993,
65
+ 5754,
66
+ -97319,
67
+ -68545,
68
+ -2582,
69
+ -70915,
70
+ -13024
71
+ ],
72
+ "output": 46
73
+ },
74
+ {
75
+ "input": [
76
+ -34148,
77
+ -80144,
78
+ -61499,
79
+ -62139,
80
+ 14674,
81
+ -47086,
82
+ 53129,
83
+ -98222,
84
+ -5593,
85
+ 96126,
86
+ -6106,
87
+ -31157,
88
+ 14553,
89
+ 66678,
90
+ 53695,
91
+ -66934,
92
+ -93114,
93
+ 2282,
94
+ 37537,
95
+ 27855,
96
+ -50787,
97
+ 28391,
98
+ 2824,
99
+ -19927,
100
+ -82417,
101
+ 64055
102
+ ],
103
+ "output": 24
104
+ },
105
+ {
106
+ "input": [
107
+ 7816,
108
+ -6842,
109
+ 55004,
110
+ 66778,
111
+ 21760,
112
+ 67754,
113
+ -68695,
114
+ 4029,
115
+ 85692,
116
+ -26164,
117
+ -51081,
118
+ -37400,
119
+ 70153,
120
+ 44023,
121
+ -85582,
122
+ 46585,
123
+ 45518,
124
+ -89498,
125
+ 54462,
126
+ -49101,
127
+ -38142,
128
+ 91991,
129
+ 70902,
130
+ -49023,
131
+ 19466,
132
+ 48518,
133
+ -52024,
134
+ -4135,
135
+ -81818,
136
+ -90783,
137
+ -40324,
138
+ 58347,
139
+ 32836,
140
+ -86955,
141
+ -29636,
142
+ 58207,
143
+ 88747,
144
+ -10281,
145
+ -64003,
146
+ 4693,
147
+ 59399,
148
+ -72581,
149
+ -19096,
150
+ -35157,
151
+ -86889,
152
+ 92053,
153
+ -83011,
154
+ 66574,
155
+ -60195,
156
+ 78251,
157
+ 74166,
158
+ 65572,
159
+ -90860,
160
+ -83983,
161
+ -47581,
162
+ 82314,
163
+ 84168,
164
+ 27979,
165
+ 54298
166
+ ],
167
+ "output": 57
168
+ },
169
+ {
170
+ "input": [
171
+ -48537,
172
+ 53316,
173
+ -66824,
174
+ 40706,
175
+ 92698,
176
+ -42067,
177
+ 42682,
178
+ 34581,
179
+ -203,
180
+ 51535,
181
+ 7930,
182
+ -28762,
183
+ -1467,
184
+ -39118,
185
+ 49859,
186
+ 32336,
187
+ -79051,
188
+ -49948,
189
+ -41809,
190
+ -77147,
191
+ 58814,
192
+ -80870,
193
+ 68523,
194
+ -30928,
195
+ 11251,
196
+ -48457,
197
+ -13212,
198
+ -37267,
199
+ 33004,
200
+ -33527,
201
+ -89673,
202
+ -57233,
203
+ 57476,
204
+ -75371,
205
+ 1157,
206
+ 38546,
207
+ -86629,
208
+ 86751,
209
+ 63665,
210
+ -85855,
211
+ 21316,
212
+ 52287,
213
+ -6622,
214
+ -64680,
215
+ 60383,
216
+ 63174,
217
+ 84645,
218
+ -25852,
219
+ -90714,
220
+ 32397,
221
+ 91472,
222
+ 2339,
223
+ -95428,
224
+ 53076,
225
+ 99849,
226
+ -94288,
227
+ -73452,
228
+ -54576,
229
+ -75936,
230
+ -88722,
231
+ 32950,
232
+ 75320,
233
+ -20035,
234
+ 82027,
235
+ -67810,
236
+ 15962,
237
+ -84434
238
+ ],
239
+ "output": 65
240
+ },
241
+ {
242
+ "input": [
243
+ 98533,
244
+ -19572,
245
+ -40152,
246
+ -32039,
247
+ 67214,
248
+ -85514,
249
+ 86953,
250
+ -17303,
251
+ 93645,
252
+ 73580,
253
+ -86199,
254
+ -24942,
255
+ -84798,
256
+ 47412,
257
+ 18474,
258
+ -93902,
259
+ 78511,
260
+ -31376,
261
+ 23698,
262
+ 10761,
263
+ -77229,
264
+ 72163,
265
+ -34755,
266
+ -99316,
267
+ 96974,
268
+ 15835,
269
+ -41249,
270
+ -33841,
271
+ 80393,
272
+ 31,
273
+ 99101,
274
+ -85898,
275
+ -82580,
276
+ -29534,
277
+ 68439,
278
+ 94500,
279
+ 17085,
280
+ 89537,
281
+ 22883,
282
+ -82115,
283
+ 3011,
284
+ -38752,
285
+ 30086,
286
+ -73079,
287
+ -67731,
288
+ -16394,
289
+ -9532,
290
+ -1368,
291
+ 66174,
292
+ 29887,
293
+ 804,
294
+ 53777,
295
+ -82793,
296
+ -46938,
297
+ -87992,
298
+ -14377,
299
+ 325,
300
+ 87291,
301
+ -43316,
302
+ -75402,
303
+ -18739,
304
+ -56660,
305
+ 15238
306
+ ],
307
+ "output": 61
308
+ },
309
+ {
310
+ "input": [
311
+ -49906,
312
+ -11166,
313
+ -92889,
314
+ -89942,
315
+ -69573,
316
+ 73074,
317
+ -11318,
318
+ 12408,
319
+ -48049,
320
+ 2102,
321
+ -80384,
322
+ 24085,
323
+ -34466
324
+ ],
325
+ "output": 11
326
+ },
327
+ {
328
+ "input": [
329
+ 25003,
330
+ -58597,
331
+ 86707,
332
+ 10511,
333
+ 52986,
334
+ -90786,
335
+ 46592,
336
+ 6930,
337
+ 74278,
338
+ -1921,
339
+ 41341,
340
+ -36393,
341
+ 5382,
342
+ 13158,
343
+ 48178,
344
+ 40128,
345
+ 19216,
346
+ 82928,
347
+ 11877,
348
+ -68250,
349
+ 40534,
350
+ 54778,
351
+ -2681
352
+ ],
353
+ "output": 21
354
+ },
355
+ {
356
+ "input": [
357
+ 77494,
358
+ 10930,
359
+ -81776,
360
+ 94536
361
+ ],
362
+ "output": 2
363
+ },
364
+ {
365
+ "input": [
366
+ 89635,
367
+ 70201,
368
+ -98214,
369
+ 11501,
370
+ -65877,
371
+ -61081,
372
+ -35998,
373
+ 88563,
374
+ -39201,
375
+ 80846,
376
+ 87557,
377
+ 48304,
378
+ -76388,
379
+ -52634,
380
+ -67564,
381
+ -20165,
382
+ -3851,
383
+ -39548,
384
+ 7917,
385
+ 29521,
386
+ 68889,
387
+ 65510,
388
+ 40528,
389
+ 29110,
390
+ -66321,
391
+ -14748,
392
+ 75517,
393
+ 26511,
394
+ 1480,
395
+ -34379,
396
+ -90498,
397
+ -43208,
398
+ -80866,
399
+ -12208,
400
+ 9564,
401
+ -65219,
402
+ 94535,
403
+ -16207,
404
+ -89167,
405
+ -68142,
406
+ -93602,
407
+ -95636,
408
+ 55989,
409
+ 58049,
410
+ -29142,
411
+ 40942,
412
+ 61806,
413
+ -63773,
414
+ -43295,
415
+ 98034,
416
+ 15318,
417
+ -86722,
418
+ -40118,
419
+ 27933,
420
+ 93888,
421
+ -74294,
422
+ 96461,
423
+ 40930,
424
+ 35035,
425
+ 5813,
426
+ 63814
427
+ ],
428
+ "output": 59
429
+ },
430
+ {
431
+ "input": [
432
+ 85320,
433
+ 42491,
434
+ 11672,
435
+ -87727,
436
+ 57694,
437
+ -62771,
438
+ -59807,
439
+ -60242,
440
+ -59011,
441
+ 86970,
442
+ -70081,
443
+ -30163,
444
+ 27806,
445
+ 76170,
446
+ -73914,
447
+ -42096,
448
+ -30305,
449
+ 87771,
450
+ -69338,
451
+ 40872,
452
+ 56745,
453
+ -23856,
454
+ 91909,
455
+ 24868,
456
+ -65390,
457
+ -55118,
458
+ -234,
459
+ 99534,
460
+ 50888,
461
+ -39228,
462
+ -85329,
463
+ 28056,
464
+ 36405,
465
+ 19571,
466
+ 72186,
467
+ -83292,
468
+ -55181,
469
+ 77844,
470
+ -2913,
471
+ -78503,
472
+ 9522,
473
+ -37564,
474
+ 46232,
475
+ 72391,
476
+ -77620,
477
+ 23466,
478
+ 61458,
479
+ -66037,
480
+ 76741,
481
+ -16057,
482
+ -76196,
483
+ 26631,
484
+ 95124,
485
+ -67797,
486
+ 81921,
487
+ 12106,
488
+ 38601,
489
+ -58596,
490
+ 65704,
491
+ 70463
492
+ ],
493
+ "output": 58
494
+ }
495
+ ],
496
+ "haskell_template": "countElements :: [Int] -> Int\ncountElements nums ",
497
+ "ocaml_template": "let countElements (nums: int list) : int = ",
498
+ "scala_template": "def countElements(nums: List[Int]): Int = { \n \n}",
499
+ "java_template": "public static int countElements(List<Integer> nums) {\n\n}",
500
+ "python_template": "class Solution(object):\n def countElements(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
501
+ }
count_elements_with_strictly_smaller_and_greater_elements/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 2 (countElements [11;7;2;15])
12
+
13
+ let test2 _ = assert_equal 2 (countElements [-3;3;3;90])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for countElements" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
count_elements_with_strictly_smaller_and_greater_elements/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.countElements(List(11,7,2,15)), 2)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.countElements(List(-3,3,3,90)), 2)
10
+ }
11
+
12
+ }
count_equal_and_divisible_pairs_in_an_array/.DS_Store ADDED
Binary file (6.15 kB). View file
 
count_equal_and_divisible_pairs_in_an_array/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (countPairs [3,1,2,2,2,1,3] 2)," 4 (countPairs [3,1,2,2,2,1,3] 2))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (countPairs [1,2,3,4] 1)," 0 (countPairs [1,2,3,4] 1))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
count_equal_and_divisible_pairs_in_an_array/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(4, countPairs(new ArrayList<>(Arrays.asList(3,1,2,2,2,1,3)), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(0, countPairs(new ArrayList<>(Arrays.asList(1,2,3,4)), 1));
19
+ }
20
+
21
+ }
count_equal_and_divisible_pairs_in_an_array/meta.json ADDED
@@ -0,0 +1,576 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2277,
3
+ "name": "count_equal_and_divisible_pairs_in_an_array",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/count-equal-and-divisible-pairs-in-an-array/",
6
+ "date": "1644019200000",
7
+ "task_description": "Given a **0-indexed** integer array `nums` of length `n` and an integer `k`, return _the **number of pairs**_ `(i, j)` _where_ `0 <= i < j < n`, _such that_ `nums[i] == nums[j]` _and_ `(i * j)` _is divisible by_ `k`. **Example 1:** ``` **Input:** nums = [3,1,2,2,2,1,3], k = 2 **Output:** 4 **Explanation:** There are 4 pairs that meet all the requirements: - nums[0] == nums[6], and 0 * 6 == 0, which is divisible by 2. - nums[2] == nums[3], and 2 * 3 == 6, which is divisible by 2. - nums[2] == nums[4], and 2 * 4 == 8, which is divisible by 2. - nums[3] == nums[4], and 3 * 4 == 12, which is divisible by 2. ``` **Example 2:** ``` **Input:** nums = [1,2,3,4], k = 1 **Output:** 0 **Explanation:** Since no value in nums is repeated, there are no pairs (i,j) that meet all the requirements. ``` **Constraints:** `1 <= nums.length <= 100` `1 <= nums[i], k <= 100`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [3,1,2,2,2,1,3], k = 2",
12
+ "output": "4 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [1,2,3,4], k = 1",
17
+ "output": "0 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ [
24
+ 39,
25
+ 64,
26
+ 19,
27
+ 86,
28
+ 48,
29
+ 65,
30
+ 45,
31
+ 55,
32
+ 51,
33
+ 90,
34
+ 99,
35
+ 66,
36
+ 54,
37
+ 56,
38
+ 6,
39
+ 94,
40
+ 35,
41
+ 94,
42
+ 64,
43
+ 32,
44
+ 53,
45
+ 86,
46
+ 93,
47
+ 52,
48
+ 34,
49
+ 31,
50
+ 25,
51
+ 64,
52
+ 59,
53
+ 98,
54
+ 47,
55
+ 39,
56
+ 24,
57
+ 9,
58
+ 61,
59
+ 51,
60
+ 87,
61
+ 50,
62
+ 51,
63
+ 64,
64
+ 24,
65
+ 90,
66
+ 12,
67
+ 56,
68
+ 32,
69
+ 17,
70
+ 85,
71
+ 4,
72
+ 94,
73
+ 36,
74
+ 57,
75
+ 11,
76
+ 38
77
+ ],
78
+ 78
79
+ ],
80
+ "output": 2
81
+ },
82
+ {
83
+ "input": [
84
+ [
85
+ 89,
86
+ 76,
87
+ 44,
88
+ 59,
89
+ 85,
90
+ 4,
91
+ 36,
92
+ 41,
93
+ 95,
94
+ 7,
95
+ 7,
96
+ 80,
97
+ 32,
98
+ 4,
99
+ 88,
100
+ 29,
101
+ 64,
102
+ 9,
103
+ 9,
104
+ 66,
105
+ 30,
106
+ 55,
107
+ 3,
108
+ 76,
109
+ 9,
110
+ 52,
111
+ 59,
112
+ 81,
113
+ 74,
114
+ 36,
115
+ 71,
116
+ 31,
117
+ 68,
118
+ 48,
119
+ 89,
120
+ 51,
121
+ 89,
122
+ 31,
123
+ 86,
124
+ 61,
125
+ 34,
126
+ 10,
127
+ 87,
128
+ 82,
129
+ 93,
130
+ 38,
131
+ 53,
132
+ 75,
133
+ 62,
134
+ 15
135
+ ],
136
+ 50
137
+ ],
138
+ "output": 2
139
+ },
140
+ {
141
+ "input": [
142
+ [
143
+ 51,
144
+ 95,
145
+ 17,
146
+ 82,
147
+ 66,
148
+ 47,
149
+ 58,
150
+ 48,
151
+ 73,
152
+ 61,
153
+ 47,
154
+ 33,
155
+ 14,
156
+ 31
157
+ ],
158
+ 60
159
+ ],
160
+ "output": 0
161
+ },
162
+ {
163
+ "input": [
164
+ [
165
+ 24,
166
+ 6,
167
+ 83,
168
+ 7,
169
+ 58,
170
+ 10,
171
+ 71,
172
+ 69,
173
+ 93,
174
+ 9,
175
+ 98,
176
+ 28,
177
+ 8,
178
+ 75,
179
+ 94,
180
+ 32,
181
+ 82,
182
+ 69,
183
+ 48,
184
+ 85,
185
+ 13,
186
+ 26,
187
+ 29,
188
+ 41,
189
+ 74,
190
+ 50,
191
+ 49,
192
+ 10,
193
+ 82,
194
+ 16,
195
+ 70,
196
+ 19,
197
+ 37,
198
+ 46,
199
+ 6,
200
+ 27,
201
+ 42,
202
+ 54,
203
+ 74,
204
+ 16,
205
+ 94,
206
+ 37,
207
+ 24,
208
+ 20,
209
+ 36,
210
+ 77,
211
+ 42
212
+ ],
213
+ 20
214
+ ],
215
+ "output": 2
216
+ },
217
+ {
218
+ "input": [
219
+ [
220
+ 60,
221
+ 87,
222
+ 53,
223
+ 86,
224
+ 48,
225
+ 16,
226
+ 60,
227
+ 83,
228
+ 74,
229
+ 3,
230
+ 10,
231
+ 89,
232
+ 88,
233
+ 2,
234
+ 88,
235
+ 73,
236
+ 73,
237
+ 84,
238
+ 20,
239
+ 97,
240
+ 38,
241
+ 34,
242
+ 37,
243
+ 23,
244
+ 35,
245
+ 89,
246
+ 18,
247
+ 49,
248
+ 45,
249
+ 83,
250
+ 82,
251
+ 10,
252
+ 30,
253
+ 28,
254
+ 81,
255
+ 44,
256
+ 63,
257
+ 68,
258
+ 28,
259
+ 55,
260
+ 26,
261
+ 42,
262
+ 63,
263
+ 83,
264
+ 97,
265
+ 96,
266
+ 51,
267
+ 15,
268
+ 64,
269
+ 75,
270
+ 29,
271
+ 13,
272
+ 29,
273
+ 14,
274
+ 46,
275
+ 30,
276
+ 77,
277
+ 48,
278
+ 3,
279
+ 66,
280
+ 8,
281
+ 17,
282
+ 27,
283
+ 61,
284
+ 81,
285
+ 13,
286
+ 74,
287
+ 3,
288
+ 56,
289
+ 39,
290
+ 28,
291
+ 85,
292
+ 64,
293
+ 3,
294
+ 14
295
+ ],
296
+ 7
297
+ ],
298
+ "output": 7
299
+ },
300
+ {
301
+ "input": [
302
+ [
303
+ 49,
304
+ 56,
305
+ 1,
306
+ 59,
307
+ 45,
308
+ 95,
309
+ 19,
310
+ 51,
311
+ 59,
312
+ 43,
313
+ 5,
314
+ 70,
315
+ 80,
316
+ 63,
317
+ 49,
318
+ 65,
319
+ 89,
320
+ 80,
321
+ 32,
322
+ 4,
323
+ 36,
324
+ 58,
325
+ 51,
326
+ 13,
327
+ 43,
328
+ 6,
329
+ 16,
330
+ 25,
331
+ 20,
332
+ 50,
333
+ 45,
334
+ 17,
335
+ 51,
336
+ 29,
337
+ 1,
338
+ 88,
339
+ 7,
340
+ 79,
341
+ 100,
342
+ 19,
343
+ 18,
344
+ 85,
345
+ 81,
346
+ 26,
347
+ 32,
348
+ 4,
349
+ 90,
350
+ 10,
351
+ 70,
352
+ 19,
353
+ 69,
354
+ 17,
355
+ 42,
356
+ 99,
357
+ 46
358
+ ],
359
+ 68
360
+ ],
361
+ "output": 3
362
+ },
363
+ {
364
+ "input": [
365
+ [
366
+ 34,
367
+ 29,
368
+ 46,
369
+ 82,
370
+ 30,
371
+ 12,
372
+ 4,
373
+ 92,
374
+ 62,
375
+ 15,
376
+ 87,
377
+ 95,
378
+ 72,
379
+ 87,
380
+ 14,
381
+ 1,
382
+ 22,
383
+ 25,
384
+ 14,
385
+ 98,
386
+ 1,
387
+ 23,
388
+ 38,
389
+ 60,
390
+ 1,
391
+ 2,
392
+ 22,
393
+ 50,
394
+ 9,
395
+ 50,
396
+ 20,
397
+ 10,
398
+ 60,
399
+ 2,
400
+ 5,
401
+ 15,
402
+ 64,
403
+ 90,
404
+ 58,
405
+ 72,
406
+ 27,
407
+ 46,
408
+ 79,
409
+ 38,
410
+ 43,
411
+ 81,
412
+ 11,
413
+ 55,
414
+ 37,
415
+ 44,
416
+ 79,
417
+ 87,
418
+ 75,
419
+ 20,
420
+ 27,
421
+ 90,
422
+ 28,
423
+ 15,
424
+ 32,
425
+ 76,
426
+ 70,
427
+ 12,
428
+ 76,
429
+ 43,
430
+ 37,
431
+ 92,
432
+ 99,
433
+ 25,
434
+ 36,
435
+ 42,
436
+ 27,
437
+ 48,
438
+ 17,
439
+ 3,
440
+ 100,
441
+ 77,
442
+ 59,
443
+ 68,
444
+ 75,
445
+ 31,
446
+ 2,
447
+ 15,
448
+ 48,
449
+ 41,
450
+ 14,
451
+ 94,
452
+ 55,
453
+ 88,
454
+ 70,
455
+ 20,
456
+ 2,
457
+ 20,
458
+ 40,
459
+ 10
460
+ ],
461
+ 42
462
+ ],
463
+ "output": 7
464
+ },
465
+ {
466
+ "input": [
467
+ [
468
+ 5,
469
+ 72,
470
+ 2,
471
+ 83,
472
+ 85,
473
+ 14,
474
+ 59,
475
+ 35,
476
+ 15,
477
+ 22,
478
+ 29,
479
+ 53,
480
+ 2,
481
+ 80,
482
+ 50,
483
+ 45,
484
+ 59,
485
+ 47
486
+ ],
487
+ 19
488
+ ],
489
+ "output": 0
490
+ },
491
+ {
492
+ "input": [
493
+ [
494
+ 16,
495
+ 10,
496
+ 30,
497
+ 74,
498
+ 23,
499
+ 64,
500
+ 100,
501
+ 83,
502
+ 65,
503
+ 16,
504
+ 37,
505
+ 28,
506
+ 3,
507
+ 62,
508
+ 24
509
+ ],
510
+ 42
511
+ ],
512
+ "output": 1
513
+ },
514
+ {
515
+ "input": [
516
+ [
517
+ 33,
518
+ 13,
519
+ 59,
520
+ 42,
521
+ 84,
522
+ 16,
523
+ 86,
524
+ 43,
525
+ 50,
526
+ 65,
527
+ 73,
528
+ 10,
529
+ 73,
530
+ 99,
531
+ 65,
532
+ 11,
533
+ 3,
534
+ 61,
535
+ 90,
536
+ 22,
537
+ 47,
538
+ 22,
539
+ 98,
540
+ 22,
541
+ 8,
542
+ 44,
543
+ 21,
544
+ 45,
545
+ 52,
546
+ 39,
547
+ 59,
548
+ 31,
549
+ 20,
550
+ 47,
551
+ 19,
552
+ 19,
553
+ 7,
554
+ 46,
555
+ 80,
556
+ 2,
557
+ 44,
558
+ 100,
559
+ 32,
560
+ 86,
561
+ 6,
562
+ 12,
563
+ 78,
564
+ 46
565
+ ],
566
+ 8
567
+ ],
568
+ "output": 2
569
+ }
570
+ ],
571
+ "haskell_template": "countPairs :: [Int] -> Int -> Int\ncountPairs nums k ",
572
+ "ocaml_template": "let countPairs (nums: int list) (k: int) : int = ",
573
+ "scala_template": "def countPairs(nums: List[Int],k: Int): Int = { \n \n}",
574
+ "java_template": "public static int countPairs(List<Integer> nums, int k) {\n\n}",
575
+ "python_template": "class Solution(object):\n def countPairs(self, nums, k):\n \"\"\"\n :type nums: List[int]\n :type k: int\n :rtype: int\n \"\"\"\n "
576
+ }
count_equal_and_divisible_pairs_in_an_array/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 4 (countPairs [3;1;2;2;2;1;3] 2)
12
+
13
+ let test2 _ = assert_equal 0 (countPairs [1;2;3;4] 1)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for countPairs" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
count_equal_and_divisible_pairs_in_an_array/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.countPairs(List(3,1,2,2,2,1,3),2), 4)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.countPairs(List(1,2,3,4),1), 0)
10
+ }
11
+
12
+ }
count_good_triplets_in_an_array/.DS_Store ADDED
Binary file (6.15 kB). View file
 
count_good_triplets_in_an_array/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (goodTriplets [2,0,1,3] [0,1,2,3])," 1 (goodTriplets [2,0,1,3] [0,1,2,3]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (goodTriplets [4,0,1,3,2] [4,1,0,2,3])," 4 (goodTriplets [4,0,1,3,2] [4,1,0,2,3]))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
count_good_triplets_in_an_array/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(1, goodTriplets(new ArrayList<>(Arrays.asList(2,0,1,3)), new ArrayList<>(Arrays.asList(0,1,2,3))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(4, goodTriplets(new ArrayList<>(Arrays.asList(4,0,1,3,2)), new ArrayList<>(Arrays.asList(4,1,0,2,3))));
19
+ }
20
+
21
+ }
count_good_triplets_in_an_array/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b18a4f9d66a909018801ecd3c8a59f93a3277526ef85dbbb52b0056afae4b24e
3
+ size 36241412
count_good_triplets_in_an_array/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 1 (goodTriplets [2;0;1;3] [0;1;2;3])
12
+
13
+ let test2 _ = assert_equal 4 (goodTriplets [4;0;1;3;2] [4;1;0;2;3])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for goodTriplets" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
count_good_triplets_in_an_array/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.goodTriplets(List(2,0,1,3),List(0,1,2,3)), 1)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.goodTriplets(List(4,0,1,3,2),List(4,1,0,2,3)), 4)
10
+ }
11
+
12
+ }
count_hills_and_valleys_in_an_array/.DS_Store ADDED
Binary file (6.15 kB). View file
 
count_hills_and_valleys_in_an_array/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (countHillValley [2,4,1,1,6,5])," 3 (countHillValley [2,4,1,1,6,5]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (countHillValley [6,6,5,5,4,1])," 0 (countHillValley [6,6,5,5,4,1]))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
count_hills_and_valleys_in_an_array/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(3, countHillValley(new ArrayList<>(Arrays.asList(2,4,1,1,6,5))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(0, countHillValley(new ArrayList<>(Arrays.asList(6,6,5,5,4,1))));
19
+ }
20
+
21
+ }