DatasetRepo commited on
Commit
893bc91
·
verified ·
1 Parent(s): e5db8da

ad921e5faff2f2cf3ba86483dabf36386cbb4b529efacf07dfa1b2d84aed393c

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 +2 -0
  2. smallest_substring_with_identical_characters_i/ocaml_tests/main.ml +50 -0
  3. smallest_substring_with_identical_characters_i/scala_tests/MySuite.scala +44 -0
  4. smallest_substring_with_identical_characters_ii/haskell_tests/Main.hs +0 -0
  5. smallest_substring_with_identical_characters_ii/java_tests/Main.java +21 -0
  6. smallest_substring_with_identical_characters_ii/meta.json +0 -0
  7. smallest_substring_with_identical_characters_ii/ocaml_tests/main.ml +0 -0
  8. smallest_substring_with_identical_characters_ii/scala_tests/MySuite.scala +0 -0
  9. snake_in_matrix/java_tests/Main.java +21 -0
  10. solving_questions_with_brainpower/.DS_Store +0 -0
  11. solving_questions_with_brainpower/haskell_tests/Main.hs +24 -0
  12. solving_questions_with_brainpower/java_tests/Main.java +21 -0
  13. solving_questions_with_brainpower/meta.json +3 -0
  14. solving_questions_with_brainpower/ocaml_tests/main.ml +26 -0
  15. solving_questions_with_brainpower/scala_tests/MySuite.scala +12 -0
  16. sort_even_and_odd_indices_independently/.DS_Store +0 -0
  17. sort_even_and_odd_indices_independently/haskell_tests/Main.hs +24 -0
  18. sort_even_and_odd_indices_independently/java_tests/Main.java +21 -0
  19. sort_even_and_odd_indices_independently/meta.json +1433 -0
  20. sort_even_and_odd_indices_independently/ocaml_tests/main.ml +26 -0
  21. sort_even_and_odd_indices_independently/scala_tests/MySuite.scala +12 -0
  22. sort_matrix_by_diagonals/haskell_tests/Main.hs +44 -0
  23. sort_matrix_by_diagonals/java_tests/Main.java +24 -0
  24. sort_matrix_by_diagonals/meta.json +594 -0
  25. sort_matrix_by_diagonals/ocaml_tests/main.ml +45 -0
  26. sort_matrix_by_diagonals/scala_tests/MySuite.scala +36 -0
  27. sort_the_people/.DS_Store +0 -0
  28. sort_the_people/haskell_tests/Main.hs +24 -0
  29. sort_the_people/java_tests/Main.java +21 -0
  30. sort_the_people/meta.json +26 -0
  31. sort_the_people/ocaml_tests/main.ml +26 -0
  32. sort_the_people/scala_tests/MySuite.scala +12 -0
  33. sort_the_students_by_their_kth_score/haskell_tests/Main.hs +0 -0
  34. sort_the_students_by_their_kth_score/java_tests/Main.java +21 -0
  35. sort_the_students_by_their_kth_score/meta.json +0 -0
  36. sort_the_students_by_their_kth_score/ocaml_tests/main.ml +0 -0
  37. sort_the_students_by_their_kth_score/scala_tests/MySuite.scala +0 -0
  38. sort_vowels_in_a_string/.DS_Store +0 -0
  39. sort_vowels_in_a_string/haskell_tests/Main.hs +24 -0
  40. sort_vowels_in_a_string/java_tests/Main.java +21 -0
  41. sort_vowels_in_a_string/meta.json +0 -0
  42. sort_vowels_in_a_string/ocaml_tests/main.ml +26 -0
  43. sort_vowels_in_a_string/scala_tests/MySuite.scala +12 -0
  44. sorted_gcd_pair_queries/haskell_tests/Main.hs +0 -0
  45. sorted_gcd_pair_queries/java_tests/Main.java +25 -0
  46. sorted_gcd_pair_queries/meta.json +3 -0
  47. sorted_gcd_pair_queries/ocaml_tests/main.ml +0 -0
  48. sorted_gcd_pair_queries/scala_tests/MySuite.scala +0 -0
  49. sorting_three_groups/.DS_Store +0 -0
  50. sorting_three_groups/haskell_tests/Main.hs +27 -0
.gitattributes CHANGED
@@ -278,3 +278,5 @@ shortest_impossible_sequence_of_rolls/meta.json filter=lfs diff=lfs merge=lfs -t
278
  shortest_subarray_with_or_at_least_k_ii/meta.json filter=lfs diff=lfs merge=lfs -text
279
  sliding_subarray_beauty/meta.json filter=lfs diff=lfs merge=lfs -text
280
  smallest_missing_non_negative_integer_after_operations/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
278
  shortest_subarray_with_or_at_least_k_ii/meta.json filter=lfs diff=lfs merge=lfs -text
279
  sliding_subarray_beauty/meta.json filter=lfs diff=lfs merge=lfs -text
280
  smallest_missing_non_negative_integer_after_operations/meta.json filter=lfs diff=lfs merge=lfs -text
281
+ solving_questions_with_brainpower/meta.json filter=lfs diff=lfs merge=lfs -text
282
+ sorted_gcd_pair_queries/meta.json filter=lfs diff=lfs merge=lfs -text
smallest_substring_with_identical_characters_i/ocaml_tests/main.ml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 (minLength "000001" 1)
12
+
13
+ let test2 _ = assert_equal 1 (minLength "0000" 2)
14
+
15
+ let test3 _ = assert_equal 1 (minLength "111011101011001101110101111010001001010111111001010111011001110100010010101010101000111110010110000010000101010100111111001101100101110010100011111000111001100101001101100101111001011010110000001110111011001010101101110110100000010100001100011110111010011110101001010010010100011011110000101010010010101101000001110110100011111101011101000010001011101110000001110101110111110111011000111001101010110101001111101000111010101001101100010011111011010101011011110001011011000100011111111100100000111110010100010100000101000111100100001010000100011011001011100001100011010111001011010101001001101001111110000001010011100001000000100011011111110001011000101000001011111100111111010011100010111001110010000100100000011111000111000110001001101010001100111100000001010111000110011101010110010010100100000100" 791)
16
+
17
+ let test4 _ = assert_equal 1 (minLength "010001010100011010001010001011011101000001011110000100101001010000100001010111110101011001000100110011111111011101101100101110001111100011110101011011000001101001111110000010001100011110100011011111010101100010000010100000" 168)
18
+
19
+ let test5 _ = assert_equal 2 (minLength "0001001111010111010011001101110100000111011111110001001110111111100110011000110001111000000110100111100110010101000101001001100100001000001100010011001110000010110111001101100101011011100010101110011010100010110010100111111111010001011001101000011000100010110001111100100111011111000000001101101101110000111010000010010011001111101111111011110011010101101101011001100111110111011001000101000101011101000101001001000010110111101011100001100000001110010110000100101010110100110100010011101011111000001001111010110111010101001101110100111110000101000000011111101100000110001010000001100001100110000111000" 255)
20
+
21
+ let test6 _ = assert_equal 1 (minLength "110101001110100001010000010010111100110001011110010111011111111101010010101000010100001000010100100101110100111001010110010000001111011110111101111001110010111111001111100100110110100000101111111001101111110101011000001011110100100010001001010101001000001001001010000001110000010110000000000101111101010011110000011001100011111101000010010011100010100001001001001000010011100010110011100010011101100111100000010110010001111101011011000100111011010000011100000101111100101101100111001111001010101011111010001110000111011101001011010100010000110000011010101010001001110101" 527)
22
+
23
+ let test7 _ = assert_equal 1 (minLength "010000110000101101001100001101010000100000110100000010010111001111001001100010111100001001101111101101101011011110100010110101001111000001111010110100001101111001110100110000010001010101101110001110000101111000111111110001100110011011100001010000010000100010010010110111100100110101111011110011111100100111010010011000000001001110101000100110110110110011011111100111000010010100000010000101001111001111110100101010001111110001001100001010110000111000010000010001110101111010011000111101110001111010011001001100011011110110101100100010010011011110010100100101010010101100001011010001011011001100000011100100010111101101111111000000010110001010001010011011100000101011110000101011001100100001111100010001011010110000000000010110011" 604)
24
+
25
+ let test8 _ = assert_equal 1 (minLength "00101110001110010110011011100000010001001101001001000100111111001010110011000001110000001100011011100111101010110011111001100111110000011101011110010111010101010010001100111101000001001001111010010111001010101110010000010101100100011010000010110100010111111011110110101110110011010011011100001011101000110111100001110111101001111100100011001011000111100001101111110111000001011100010011111010110100010100000100111000100101101100010110100110110100011101010000111100010001010010110110001101010010001111010010101010111000000001111001101" 487)
26
+
27
+ let test9 _ = assert_equal 1 (minLength "1101" 1)
28
+
29
+ let test10 _ = assert_equal 7 (minLength "100000011100001001001011010101110000000000011011010001111101110011101000101010010010100111100111001000010101000000010000000011010001011000101101001110101010100101110111100001001011100001010100100000110111100000111000111111010101000111100110111010100110101100110010000100000000111000001011111111111111100111011001001100101010101000100000110101100111110100100101110110000000000011111100010110111011000001001001110011101110011111010100110011000000000111011100010010101100101000010010100101101010100000000001001011001000010010011111110100110110011111101111111001101110110010011011011110001001100000010010010011101100011100100001111010100111001101000001001010100110110010101111111111111100010101000010001000" 11)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for minLength" >::: [
34
+
35
+ "test1" >:: test1;
36
+ "test2" >:: test2;
37
+ "test3" >:: test3;
38
+ "test4" >:: test4;
39
+ "test5" >:: test5;
40
+ "test6" >:: test6;
41
+ "test7" >:: test7;
42
+ "test8" >:: test8;
43
+ "test9" >:: test9;
44
+ "test10" >:: test10;
45
+ ]
46
+
47
+
48
+ (* Running the tests *)
49
+ let () = run_test_tt_main suite
50
+ end
smallest_substring_with_identical_characters_i/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minLength("000001",1), 2)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minLength("0000",2), 1)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minLength("111011101011001101110101111010001001010111111001010111011001110100010010101010101000111110010110000010000101010100111111001101100101110010100011111000111001100101001101100101111001011010110000001110111011001010101101110110100000010100001100011110111010011110101001010010010100011011110000101010010010101101000001110110100011111101011101000010001011101110000001110101110111110111011000111001101010110101001111101000111010101001101100010011111011010101011011110001011011000100011111111100100000111110010100010100000101000111100100001010000100011011001011100001100011010111001011010101001001101001111110000001010011100001000000100011011111110001011000101000001011111100111111010011100010111001110010000100100000011111000111000110001001101010001100111100000001010111000110011101010110010010100100000100",791), 1)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minLength("010001010100011010001010001011011101000001011110000100101001010000100001010111110101011001000100110011111111011101101100101110001111100011110101011011000001101001111110000010001100011110100011011111010101100010000010100000",168), 1)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minLength("0001001111010111010011001101110100000111011111110001001110111111100110011000110001111000000110100111100110010101000101001001100100001000001100010011001110000010110111001101100101011011100010101110011010100010110010100111111111010001011001101000011000100010110001111100100111011111000000001101101101110000111010000010010011001111101111111011110011010101101101011001100111110111011001000101000101011101000101001001000010110111101011100001100000001110010110000100101010110100110100010011101011111000001001111010110111010101001101110100111110000101000000011111101100000110001010000001100001100110000111000",255), 2)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minLength("110101001110100001010000010010111100110001011110010111011111111101010010101000010100001000010100100101110100111001010110010000001111011110111101111001110010111111001111100100110110100000101111111001101111110101011000001011110100100010001001010101001000001001001010000001110000010110000000000101111101010011110000011001100011111101000010010011100010100001001001001000010011100010110011100010011101100111100000010110010001111101011011000100111011010000011100000101111100101101100111001111001010101011111010001110000111011101001011010100010000110000011010101010001001110101",527), 1)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minLength("010000110000101101001100001101010000100000110100000010010111001111001001100010111100001001101111101101101011011110100010110101001111000001111010110100001101111001110100110000010001010101101110001110000101111000111111110001100110011011100001010000010000100010010010110111100100110101111011110011111100100111010010011000000001001110101000100110110110110011011111100111000010010100000010000101001111001111110100101010001111110001001100001010110000111000010000010001110101111010011000111101110001111010011001001100011011110110101100100010010011011110010100100101010010101100001011010001011011001100000011100100010111101101111111000000010110001010001010011011100000101011110000101011001100100001111100010001011010110000000000010110011",604), 1)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minLength("00101110001110010110011011100000010001001101001001000100111111001010110011000001110000001100011011100111101010110011111001100111110000011101011110010111010101010010001100111101000001001001111010010111001010101110010000010101100100011010000010110100010111111011110110101110110011010011011100001011101000110111100001110111101001111100100011001011000111100001101111110111000001011100010011111010110100010100000100111000100101101100010110100110110100011101010000111100010001010010110110001101010010001111010010101010111000000001111001101",487), 1)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.minLength("1101",1), 1)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.minLength("100000011100001001001011010101110000000000011011010001111101110011101000101010010010100111100111001000010101000000010000000011010001011000101101001110101010100101110111100001001011100001010100100000110111100000111000111111010101000111100110111010100110101100110010000100000000111000001011111111111111100111011001001100101010101000100000110101100111110100100101110110000000000011111100010110111011000001001001110011101110011111010100110011000000000111011100010010101100101000010010100101101010100000000001001011001000010010011111110100110110011111101111111001101110110010011011011110001001100000010010010011101100011100100001111010100111001101000001001010100110110010101111111111111100010101000010001000",11), 7)
42
+ }
43
+
44
+ }
smallest_substring_with_identical_characters_ii/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
smallest_substring_with_identical_characters_ii/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, minLength("000001", 1));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(1, minLength("0000", 2));
19
+ }
20
+
21
+ }
smallest_substring_with_identical_characters_ii/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
smallest_substring_with_identical_characters_ii/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
smallest_substring_with_identical_characters_ii/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
snake_in_matrix/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, finalPositionOfSnake(2, new ArrayList<>(Arrays.asList("RIGHT","DOWN"))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(1, finalPositionOfSnake(3, new ArrayList<>(Arrays.asList("DOWN","RIGHT","UP"))));
19
+ }
20
+
21
+ }
solving_questions_with_brainpower/.DS_Store ADDED
Binary file (6.15 kB). View file
 
solving_questions_with_brainpower/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 (mostPoints [[3,2],[4,3],[4,4],[2,5]])," 5 (mostPoints [[3,2],[4,3],[4,4],[2,5]]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (mostPoints [[1,1],[2,2],[3,3],[4,4],[5,5]])," 7 (mostPoints [[1,1],[2,2],[3,3],[4,4],[5,5]]))
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
solving_questions_with_brainpower/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(5, mostPoints(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(3,2)),new ArrayList<>(Arrays.asList(4,3)),new ArrayList<>(Arrays.asList(4,4)),new ArrayList<>(Arrays.asList(2,5))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(7, mostPoints(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,1)),new ArrayList<>(Arrays.asList(2,2)),new ArrayList<>(Arrays.asList(3,3)),new ArrayList<>(Arrays.asList(4,4)),new ArrayList<>(Arrays.asList(5,5))))));
19
+ }
20
+
21
+ }
solving_questions_with_brainpower/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c518619cc6a454c8ef98c723267c19464ed1303008df4926fc2dbc24c3d9b33
3
+ size 34646134
solving_questions_with_brainpower/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 5 (mostPoints [[3;2];[4;3];[4;4];[2;5]])
12
+
13
+ let test2 _ = assert_equal 7 (mostPoints [[1;1];[2;2];[3;3];[4;4];[5;5]])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for mostPoints" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
solving_questions_with_brainpower/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.mostPoints(List(List(3,2),List(4,3),List(4,4),List(2,5))), 5)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.mostPoints(List(List(1,1),List(2,2),List(3,3),List(4,4),List(5,5))), 7)
10
+ }
11
+
12
+ }
sort_even_and_odd_indices_independently/.DS_Store ADDED
Binary file (6.15 kB). View file
 
sort_even_and_odd_indices_independently/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 (sortEvenOdd [4,1,2,3])," [2,3,4,1] (sortEvenOdd [4,1,2,3]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (sortEvenOdd [2,1])," [2,1] (sortEvenOdd [2,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
sort_even_and_odd_indices_independently/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(new ArrayList<>(Arrays.asList(2,3,4,1)), sortEvenOdd(new ArrayList<>(Arrays.asList(4,1,2,3))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(2,1)), sortEvenOdd(new ArrayList<>(Arrays.asList(2,1))));
19
+ }
20
+
21
+ }
sort_even_and_odd_indices_independently/meta.json ADDED
@@ -0,0 +1,1433 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2283,
3
+ "name": "sort_even_and_odd_indices_independently",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/sort-even-and-odd-indices-independently/",
6
+ "date": "1643500800000",
7
+ "task_description": "You are given a **0-indexed** integer array `nums`. Rearrange the values of `nums` according to the following rules: Sort the values at **odd indices** of `nums` in **non-increasing** order. For example, if `nums = [4,**1**,2,**3**]` before this step, it becomes `[4,**3**,2,**1**]` after. The values at odd indices `1` and `3` are sorted in non-increasing order. Sort the values at **even indices** of `nums` in **non-decreasing** order. For example, if `nums = [**4**,1,**2**,3]` before this step, it becomes `[**2**,1,**4**,3]` after. The values at even indices `0` and `2` are sorted in non-decreasing order. Return _the array formed after rearranging the values of_ `nums`. **Example 1:** ``` **Input:** nums = [4,1,2,3] **Output:** [2,3,4,1] **Explanation:** First, we sort the values present at odd indices (1 and 3) in non-increasing order. So, nums changes from [4,**1**,2,**3**] to [4,**3**,2,**1**]. Next, we sort the values present at even indices (0 and 2) in non-decreasing order. So, nums changes from [**4**,1,**2**,3] to [**2**,3,**4**,1]. Thus, the array formed after rearranging the values is [2,3,4,1]. ``` **Example 2:** ``` **Input:** nums = [2,1] **Output:** [2,1] **Explanation:** Since there is exactly one odd index and one even index, no rearrangement of values takes place. The resultant array formed is [2,1], which is the same as the initial array. ``` **Constraints:** `1 <= nums.length <= 100` `1 <= nums[i] <= 100`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [4,1,2,3]",
12
+ "output": "[2,3,4,1] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [2,1]",
17
+ "output": "[2,1] "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 1,
24
+ 95,
25
+ 2,
26
+ 93,
27
+ 6,
28
+ 90,
29
+ 15,
30
+ 85,
31
+ 15,
32
+ 82,
33
+ 21,
34
+ 81,
35
+ 26,
36
+ 76,
37
+ 34,
38
+ 76,
39
+ 35,
40
+ 75,
41
+ 38,
42
+ 71,
43
+ 38,
44
+ 70,
45
+ 38,
46
+ 68,
47
+ 39,
48
+ 67,
49
+ 40,
50
+ 67,
51
+ 40,
52
+ 66,
53
+ 43,
54
+ 64,
55
+ 45,
56
+ 64,
57
+ 45,
58
+ 63,
59
+ 45,
60
+ 61,
61
+ 46,
62
+ 60,
63
+ 47,
64
+ 58,
65
+ 47,
66
+ 54,
67
+ 48,
68
+ 54,
69
+ 50,
70
+ 53,
71
+ 50,
72
+ 52,
73
+ 53,
74
+ 50,
75
+ 53,
76
+ 43,
77
+ 54,
78
+ 42,
79
+ 55,
80
+ 35,
81
+ 55,
82
+ 34,
83
+ 56,
84
+ 32,
85
+ 57,
86
+ 28,
87
+ 58,
88
+ 25,
89
+ 60,
90
+ 25,
91
+ 60,
92
+ 25,
93
+ 63,
94
+ 22,
95
+ 70,
96
+ 22,
97
+ 77,
98
+ 22,
99
+ 77,
100
+ 14,
101
+ 78,
102
+ 13,
103
+ 80,
104
+ 12,
105
+ 83,
106
+ 12,
107
+ 84,
108
+ 10,
109
+ 88,
110
+ 6,
111
+ 88,
112
+ 6,
113
+ 90,
114
+ 5,
115
+ 92,
116
+ 2,
117
+ 95,
118
+ 1,
119
+ 97,
120
+ 1,
121
+ 100
122
+ ],
123
+ "output": [
124
+ 1,
125
+ 95,
126
+ 2,
127
+ 93,
128
+ 6,
129
+ 90,
130
+ 15,
131
+ 85,
132
+ 15,
133
+ 82,
134
+ 21,
135
+ 81,
136
+ 26,
137
+ 76,
138
+ 34,
139
+ 76,
140
+ 35,
141
+ 75,
142
+ 38,
143
+ 71,
144
+ 38,
145
+ 70,
146
+ 38,
147
+ 68,
148
+ 39,
149
+ 67,
150
+ 40,
151
+ 67,
152
+ 40,
153
+ 66,
154
+ 43,
155
+ 64,
156
+ 45,
157
+ 64,
158
+ 45,
159
+ 63,
160
+ 45,
161
+ 61,
162
+ 46,
163
+ 60,
164
+ 47,
165
+ 58,
166
+ 47,
167
+ 54,
168
+ 48,
169
+ 54,
170
+ 50,
171
+ 53,
172
+ 50,
173
+ 52,
174
+ 53,
175
+ 50,
176
+ 53,
177
+ 43,
178
+ 54,
179
+ 42,
180
+ 55,
181
+ 35,
182
+ 55,
183
+ 34,
184
+ 56,
185
+ 32,
186
+ 57,
187
+ 28,
188
+ 58,
189
+ 25,
190
+ 60,
191
+ 25,
192
+ 60,
193
+ 25,
194
+ 63,
195
+ 22,
196
+ 70,
197
+ 22,
198
+ 77,
199
+ 22,
200
+ 77,
201
+ 14,
202
+ 78,
203
+ 13,
204
+ 80,
205
+ 12,
206
+ 83,
207
+ 12,
208
+ 84,
209
+ 10,
210
+ 88,
211
+ 6,
212
+ 88,
213
+ 6,
214
+ 90,
215
+ 5,
216
+ 92,
217
+ 2,
218
+ 95,
219
+ 1,
220
+ 97,
221
+ 1,
222
+ 100
223
+ ]
224
+ },
225
+ {
226
+ "input": [
227
+ 12,
228
+ 98,
229
+ 23,
230
+ 97,
231
+ 29,
232
+ 88,
233
+ 38,
234
+ 88,
235
+ 40,
236
+ 80,
237
+ 54,
238
+ 77,
239
+ 55,
240
+ 74,
241
+ 57,
242
+ 63,
243
+ 60,
244
+ 61,
245
+ 61,
246
+ 49,
247
+ 62,
248
+ 46,
249
+ 74,
250
+ 30,
251
+ 80,
252
+ 27,
253
+ 82,
254
+ 22,
255
+ 84,
256
+ 15,
257
+ 92,
258
+ 7,
259
+ 94,
260
+ 2,
261
+ 96
262
+ ],
263
+ "output": [
264
+ 12,
265
+ 98,
266
+ 23,
267
+ 97,
268
+ 29,
269
+ 88,
270
+ 38,
271
+ 88,
272
+ 40,
273
+ 80,
274
+ 54,
275
+ 77,
276
+ 55,
277
+ 74,
278
+ 57,
279
+ 63,
280
+ 60,
281
+ 61,
282
+ 61,
283
+ 49,
284
+ 62,
285
+ 46,
286
+ 74,
287
+ 30,
288
+ 80,
289
+ 27,
290
+ 82,
291
+ 22,
292
+ 84,
293
+ 15,
294
+ 92,
295
+ 7,
296
+ 94,
297
+ 2,
298
+ 96
299
+ ]
300
+ },
301
+ {
302
+ "input": [
303
+ 2,
304
+ 96,
305
+ 3,
306
+ 87,
307
+ 4,
308
+ 80,
309
+ 9,
310
+ 74,
311
+ 12,
312
+ 69,
313
+ 15,
314
+ 54,
315
+ 15,
316
+ 52,
317
+ 17,
318
+ 48,
319
+ 18,
320
+ 41,
321
+ 29,
322
+ 37,
323
+ 30,
324
+ 37,
325
+ 32,
326
+ 37,
327
+ 35,
328
+ 36,
329
+ 55,
330
+ 25,
331
+ 56,
332
+ 21,
333
+ 56,
334
+ 20,
335
+ 68,
336
+ 18,
337
+ 69,
338
+ 16,
339
+ 73,
340
+ 10,
341
+ 87,
342
+ 9,
343
+ 96
344
+ ],
345
+ "output": [
346
+ 2,
347
+ 96,
348
+ 3,
349
+ 87,
350
+ 4,
351
+ 80,
352
+ 9,
353
+ 74,
354
+ 12,
355
+ 69,
356
+ 15,
357
+ 54,
358
+ 15,
359
+ 52,
360
+ 17,
361
+ 48,
362
+ 18,
363
+ 41,
364
+ 29,
365
+ 37,
366
+ 30,
367
+ 37,
368
+ 32,
369
+ 37,
370
+ 35,
371
+ 36,
372
+ 55,
373
+ 25,
374
+ 56,
375
+ 21,
376
+ 56,
377
+ 20,
378
+ 68,
379
+ 18,
380
+ 69,
381
+ 16,
382
+ 73,
383
+ 10,
384
+ 87,
385
+ 9,
386
+ 96
387
+ ]
388
+ },
389
+ {
390
+ "input": [
391
+ 1,
392
+ 93,
393
+ 19,
394
+ 91,
395
+ 23,
396
+ 82,
397
+ 36,
398
+ 74,
399
+ 37,
400
+ 69,
401
+ 45,
402
+ 69,
403
+ 50,
404
+ 66,
405
+ 59,
406
+ 64,
407
+ 60,
408
+ 63,
409
+ 62,
410
+ 61,
411
+ 62,
412
+ 54,
413
+ 64,
414
+ 49,
415
+ 66,
416
+ 47,
417
+ 73,
418
+ 44,
419
+ 74,
420
+ 40,
421
+ 83,
422
+ 26,
423
+ 84,
424
+ 24,
425
+ 87
426
+ ],
427
+ "output": [
428
+ 1,
429
+ 93,
430
+ 19,
431
+ 91,
432
+ 23,
433
+ 82,
434
+ 36,
435
+ 74,
436
+ 37,
437
+ 69,
438
+ 45,
439
+ 69,
440
+ 50,
441
+ 66,
442
+ 59,
443
+ 64,
444
+ 60,
445
+ 63,
446
+ 62,
447
+ 61,
448
+ 62,
449
+ 54,
450
+ 64,
451
+ 49,
452
+ 66,
453
+ 47,
454
+ 73,
455
+ 44,
456
+ 74,
457
+ 40,
458
+ 83,
459
+ 26,
460
+ 84,
461
+ 24,
462
+ 87
463
+ ]
464
+ },
465
+ {
466
+ "input": [
467
+ 2,
468
+ 84,
469
+ 4,
470
+ 80,
471
+ 18,
472
+ 79,
473
+ 20,
474
+ 78,
475
+ 32,
476
+ 78,
477
+ 35,
478
+ 77,
479
+ 37,
480
+ 69,
481
+ 38,
482
+ 69,
483
+ 43,
484
+ 67,
485
+ 45,
486
+ 63,
487
+ 46,
488
+ 63,
489
+ 50,
490
+ 55,
491
+ 51,
492
+ 38,
493
+ 57,
494
+ 32,
495
+ 61,
496
+ 29,
497
+ 63,
498
+ 28,
499
+ 68,
500
+ 20,
501
+ 70,
502
+ 18,
503
+ 72,
504
+ 18,
505
+ 79,
506
+ 13,
507
+ 79,
508
+ 12,
509
+ 91,
510
+ 11,
511
+ 95,
512
+ 2
513
+ ],
514
+ "output": [
515
+ 2,
516
+ 84,
517
+ 4,
518
+ 80,
519
+ 18,
520
+ 79,
521
+ 20,
522
+ 78,
523
+ 32,
524
+ 78,
525
+ 35,
526
+ 77,
527
+ 37,
528
+ 69,
529
+ 38,
530
+ 69,
531
+ 43,
532
+ 67,
533
+ 45,
534
+ 63,
535
+ 46,
536
+ 63,
537
+ 50,
538
+ 55,
539
+ 51,
540
+ 38,
541
+ 57,
542
+ 32,
543
+ 61,
544
+ 29,
545
+ 63,
546
+ 28,
547
+ 68,
548
+ 20,
549
+ 70,
550
+ 18,
551
+ 72,
552
+ 18,
553
+ 79,
554
+ 13,
555
+ 79,
556
+ 12,
557
+ 91,
558
+ 11,
559
+ 95,
560
+ 2
561
+ ]
562
+ },
563
+ {
564
+ "input": [
565
+ 5,
566
+ 95,
567
+ 6,
568
+ 93,
569
+ 12,
570
+ 89,
571
+ 13,
572
+ 83,
573
+ 16,
574
+ 80,
575
+ 17,
576
+ 76,
577
+ 17,
578
+ 73,
579
+ 20,
580
+ 72,
581
+ 20,
582
+ 70,
583
+ 22,
584
+ 69,
585
+ 22,
586
+ 69,
587
+ 24,
588
+ 69,
589
+ 28,
590
+ 68,
591
+ 30,
592
+ 64,
593
+ 30,
594
+ 64,
595
+ 33,
596
+ 63,
597
+ 34,
598
+ 60,
599
+ 35,
600
+ 59,
601
+ 40,
602
+ 58,
603
+ 46,
604
+ 57,
605
+ 50,
606
+ 54,
607
+ 50,
608
+ 51,
609
+ 54,
610
+ 51,
611
+ 59,
612
+ 47,
613
+ 60,
614
+ 45,
615
+ 66,
616
+ 39,
617
+ 72,
618
+ 36,
619
+ 75,
620
+ 28,
621
+ 77,
622
+ 27,
623
+ 82,
624
+ 25,
625
+ 83,
626
+ 25,
627
+ 85,
628
+ 25,
629
+ 87,
630
+ 23,
631
+ 88,
632
+ 22,
633
+ 90,
634
+ 17,
635
+ 91,
636
+ 14,
637
+ 91,
638
+ 12,
639
+ 95,
640
+ 9,
641
+ 95,
642
+ 7,
643
+ 100,
644
+ 6
645
+ ],
646
+ "output": [
647
+ 5,
648
+ 95,
649
+ 6,
650
+ 93,
651
+ 12,
652
+ 89,
653
+ 13,
654
+ 83,
655
+ 16,
656
+ 80,
657
+ 17,
658
+ 76,
659
+ 17,
660
+ 73,
661
+ 20,
662
+ 72,
663
+ 20,
664
+ 70,
665
+ 22,
666
+ 69,
667
+ 22,
668
+ 69,
669
+ 24,
670
+ 69,
671
+ 28,
672
+ 68,
673
+ 30,
674
+ 64,
675
+ 30,
676
+ 64,
677
+ 33,
678
+ 63,
679
+ 34,
680
+ 60,
681
+ 35,
682
+ 59,
683
+ 40,
684
+ 58,
685
+ 46,
686
+ 57,
687
+ 50,
688
+ 54,
689
+ 50,
690
+ 51,
691
+ 54,
692
+ 51,
693
+ 59,
694
+ 47,
695
+ 60,
696
+ 45,
697
+ 66,
698
+ 39,
699
+ 72,
700
+ 36,
701
+ 75,
702
+ 28,
703
+ 77,
704
+ 27,
705
+ 82,
706
+ 25,
707
+ 83,
708
+ 25,
709
+ 85,
710
+ 25,
711
+ 87,
712
+ 23,
713
+ 88,
714
+ 22,
715
+ 90,
716
+ 17,
717
+ 91,
718
+ 14,
719
+ 91,
720
+ 12,
721
+ 95,
722
+ 9,
723
+ 95,
724
+ 7,
725
+ 100,
726
+ 6
727
+ ]
728
+ },
729
+ {
730
+ "input": [
731
+ 1,
732
+ 100,
733
+ 4,
734
+ 97,
735
+ 4,
736
+ 94,
737
+ 12,
738
+ 94,
739
+ 15,
740
+ 91,
741
+ 19,
742
+ 88,
743
+ 20,
744
+ 87,
745
+ 26,
746
+ 87,
747
+ 26,
748
+ 86,
749
+ 28,
750
+ 83,
751
+ 29,
752
+ 83,
753
+ 30,
754
+ 78,
755
+ 34,
756
+ 77,
757
+ 35,
758
+ 69,
759
+ 49,
760
+ 66,
761
+ 51,
762
+ 65,
763
+ 53,
764
+ 63,
765
+ 62,
766
+ 59,
767
+ 66,
768
+ 58,
769
+ 67,
770
+ 56,
771
+ 70,
772
+ 54,
773
+ 72,
774
+ 53,
775
+ 72,
776
+ 41,
777
+ 72,
778
+ 36,
779
+ 73,
780
+ 31,
781
+ 74,
782
+ 30,
783
+ 77,
784
+ 30,
785
+ 82,
786
+ 29,
787
+ 84,
788
+ 26,
789
+ 95,
790
+ 22,
791
+ 95,
792
+ 21,
793
+ 96,
794
+ 21,
795
+ 97,
796
+ 12,
797
+ 98,
798
+ 9,
799
+ 98,
800
+ 5,
801
+ 99,
802
+ 3,
803
+ 99
804
+ ],
805
+ "output": [
806
+ 1,
807
+ 100,
808
+ 4,
809
+ 97,
810
+ 4,
811
+ 94,
812
+ 12,
813
+ 94,
814
+ 15,
815
+ 91,
816
+ 19,
817
+ 88,
818
+ 20,
819
+ 87,
820
+ 26,
821
+ 87,
822
+ 26,
823
+ 86,
824
+ 28,
825
+ 83,
826
+ 29,
827
+ 83,
828
+ 30,
829
+ 78,
830
+ 34,
831
+ 77,
832
+ 35,
833
+ 69,
834
+ 49,
835
+ 66,
836
+ 51,
837
+ 65,
838
+ 53,
839
+ 63,
840
+ 62,
841
+ 59,
842
+ 66,
843
+ 58,
844
+ 67,
845
+ 56,
846
+ 70,
847
+ 54,
848
+ 72,
849
+ 53,
850
+ 72,
851
+ 41,
852
+ 72,
853
+ 36,
854
+ 73,
855
+ 31,
856
+ 74,
857
+ 30,
858
+ 77,
859
+ 30,
860
+ 82,
861
+ 29,
862
+ 84,
863
+ 26,
864
+ 95,
865
+ 22,
866
+ 95,
867
+ 21,
868
+ 96,
869
+ 21,
870
+ 97,
871
+ 12,
872
+ 98,
873
+ 9,
874
+ 98,
875
+ 5,
876
+ 99,
877
+ 3,
878
+ 99
879
+ ]
880
+ },
881
+ {
882
+ "input": [
883
+ 2,
884
+ 94,
885
+ 3,
886
+ 93,
887
+ 4,
888
+ 87,
889
+ 5,
890
+ 86,
891
+ 10,
892
+ 85,
893
+ 12,
894
+ 84,
895
+ 13,
896
+ 84,
897
+ 14,
898
+ 83,
899
+ 14,
900
+ 82,
901
+ 19,
902
+ 81,
903
+ 19,
904
+ 79,
905
+ 24,
906
+ 78,
907
+ 26,
908
+ 77,
909
+ 27,
910
+ 77,
911
+ 28,
912
+ 76,
913
+ 30,
914
+ 75,
915
+ 31,
916
+ 69,
917
+ 31,
918
+ 68,
919
+ 33,
920
+ 62,
921
+ 36,
922
+ 61,
923
+ 37,
924
+ 58,
925
+ 40,
926
+ 57,
927
+ 44,
928
+ 56,
929
+ 48,
930
+ 54,
931
+ 48,
932
+ 54,
933
+ 49,
934
+ 50,
935
+ 57,
936
+ 45,
937
+ 57,
938
+ 44,
939
+ 57,
940
+ 42,
941
+ 59,
942
+ 40,
943
+ 59,
944
+ 37,
945
+ 64,
946
+ 37,
947
+ 67,
948
+ 34,
949
+ 72,
950
+ 31,
951
+ 76,
952
+ 30,
953
+ 78,
954
+ 22,
955
+ 78,
956
+ 18,
957
+ 80,
958
+ 15,
959
+ 80,
960
+ 13,
961
+ 80,
962
+ 9,
963
+ 81,
964
+ 9,
965
+ 86,
966
+ 5,
967
+ 90,
968
+ 5,
969
+ 92,
970
+ 3,
971
+ 100,
972
+ 1
973
+ ],
974
+ "output": [
975
+ 2,
976
+ 94,
977
+ 3,
978
+ 93,
979
+ 4,
980
+ 87,
981
+ 5,
982
+ 86,
983
+ 10,
984
+ 85,
985
+ 12,
986
+ 84,
987
+ 13,
988
+ 84,
989
+ 14,
990
+ 83,
991
+ 14,
992
+ 82,
993
+ 19,
994
+ 81,
995
+ 19,
996
+ 79,
997
+ 24,
998
+ 78,
999
+ 26,
1000
+ 77,
1001
+ 27,
1002
+ 77,
1003
+ 28,
1004
+ 76,
1005
+ 30,
1006
+ 75,
1007
+ 31,
1008
+ 69,
1009
+ 31,
1010
+ 68,
1011
+ 33,
1012
+ 62,
1013
+ 36,
1014
+ 61,
1015
+ 37,
1016
+ 58,
1017
+ 40,
1018
+ 57,
1019
+ 44,
1020
+ 56,
1021
+ 48,
1022
+ 54,
1023
+ 48,
1024
+ 54,
1025
+ 49,
1026
+ 50,
1027
+ 57,
1028
+ 45,
1029
+ 57,
1030
+ 44,
1031
+ 57,
1032
+ 42,
1033
+ 59,
1034
+ 40,
1035
+ 59,
1036
+ 37,
1037
+ 64,
1038
+ 37,
1039
+ 67,
1040
+ 34,
1041
+ 72,
1042
+ 31,
1043
+ 76,
1044
+ 30,
1045
+ 78,
1046
+ 22,
1047
+ 78,
1048
+ 18,
1049
+ 80,
1050
+ 15,
1051
+ 80,
1052
+ 13,
1053
+ 80,
1054
+ 9,
1055
+ 81,
1056
+ 9,
1057
+ 86,
1058
+ 5,
1059
+ 90,
1060
+ 5,
1061
+ 92,
1062
+ 3,
1063
+ 100,
1064
+ 1
1065
+ ]
1066
+ },
1067
+ {
1068
+ "input": [
1069
+ 1,
1070
+ 96,
1071
+ 5,
1072
+ 96,
1073
+ 8,
1074
+ 95,
1075
+ 9,
1076
+ 89,
1077
+ 15,
1078
+ 87,
1079
+ 16,
1080
+ 86,
1081
+ 17,
1082
+ 85,
1083
+ 17,
1084
+ 85,
1085
+ 21,
1086
+ 83,
1087
+ 22,
1088
+ 81,
1089
+ 27,
1090
+ 81,
1091
+ 27,
1092
+ 79,
1093
+ 28,
1094
+ 79,
1095
+ 29,
1096
+ 67,
1097
+ 32,
1098
+ 67,
1099
+ 34,
1100
+ 66,
1101
+ 35,
1102
+ 63,
1103
+ 36,
1104
+ 63,
1105
+ 40,
1106
+ 63,
1107
+ 45,
1108
+ 61,
1109
+ 52,
1110
+ 59,
1111
+ 54,
1112
+ 58,
1113
+ 54,
1114
+ 55,
1115
+ 57,
1116
+ 44,
1117
+ 58,
1118
+ 41,
1119
+ 61,
1120
+ 40,
1121
+ 67,
1122
+ 38,
1123
+ 67,
1124
+ 33,
1125
+ 67,
1126
+ 29,
1127
+ 67,
1128
+ 27,
1129
+ 68,
1130
+ 27,
1131
+ 74,
1132
+ 27,
1133
+ 76,
1134
+ 21,
1135
+ 78,
1136
+ 19,
1137
+ 85,
1138
+ 19,
1139
+ 85,
1140
+ 16,
1141
+ 86,
1142
+ 11,
1143
+ 89,
1144
+ 7,
1145
+ 90,
1146
+ 6,
1147
+ 96,
1148
+ 3,
1149
+ 99,
1150
+ 2,
1151
+ 99,
1152
+ 2,
1153
+ 100,
1154
+ 2,
1155
+ 100
1156
+ ],
1157
+ "output": [
1158
+ 1,
1159
+ 96,
1160
+ 5,
1161
+ 96,
1162
+ 8,
1163
+ 95,
1164
+ 9,
1165
+ 89,
1166
+ 15,
1167
+ 87,
1168
+ 16,
1169
+ 86,
1170
+ 17,
1171
+ 85,
1172
+ 17,
1173
+ 85,
1174
+ 21,
1175
+ 83,
1176
+ 22,
1177
+ 81,
1178
+ 27,
1179
+ 81,
1180
+ 27,
1181
+ 79,
1182
+ 28,
1183
+ 79,
1184
+ 29,
1185
+ 67,
1186
+ 32,
1187
+ 67,
1188
+ 34,
1189
+ 66,
1190
+ 35,
1191
+ 63,
1192
+ 36,
1193
+ 63,
1194
+ 40,
1195
+ 63,
1196
+ 45,
1197
+ 61,
1198
+ 52,
1199
+ 59,
1200
+ 54,
1201
+ 58,
1202
+ 54,
1203
+ 55,
1204
+ 57,
1205
+ 44,
1206
+ 58,
1207
+ 41,
1208
+ 61,
1209
+ 40,
1210
+ 67,
1211
+ 38,
1212
+ 67,
1213
+ 33,
1214
+ 67,
1215
+ 29,
1216
+ 67,
1217
+ 27,
1218
+ 68,
1219
+ 27,
1220
+ 74,
1221
+ 27,
1222
+ 76,
1223
+ 21,
1224
+ 78,
1225
+ 19,
1226
+ 85,
1227
+ 19,
1228
+ 85,
1229
+ 16,
1230
+ 86,
1231
+ 11,
1232
+ 89,
1233
+ 7,
1234
+ 90,
1235
+ 6,
1236
+ 96,
1237
+ 3,
1238
+ 99,
1239
+ 2,
1240
+ 99,
1241
+ 2,
1242
+ 100,
1243
+ 2,
1244
+ 100
1245
+ ]
1246
+ },
1247
+ {
1248
+ "input": [
1249
+ 2,
1250
+ 100,
1251
+ 5,
1252
+ 97,
1253
+ 7,
1254
+ 93,
1255
+ 11,
1256
+ 91,
1257
+ 16,
1258
+ 88,
1259
+ 19,
1260
+ 86,
1261
+ 21,
1262
+ 86,
1263
+ 22,
1264
+ 84,
1265
+ 23,
1266
+ 82,
1267
+ 23,
1268
+ 79,
1269
+ 24,
1270
+ 78,
1271
+ 24,
1272
+ 75,
1273
+ 25,
1274
+ 73,
1275
+ 28,
1276
+ 70,
1277
+ 31,
1278
+ 70,
1279
+ 31,
1280
+ 66,
1281
+ 38,
1282
+ 65,
1283
+ 42,
1284
+ 65,
1285
+ 44,
1286
+ 64,
1287
+ 46,
1288
+ 61,
1289
+ 57,
1290
+ 59,
1291
+ 57,
1292
+ 56,
1293
+ 57,
1294
+ 56,
1295
+ 57,
1296
+ 54,
1297
+ 57,
1298
+ 46,
1299
+ 61,
1300
+ 46,
1301
+ 64,
1302
+ 45,
1303
+ 64,
1304
+ 43,
1305
+ 64,
1306
+ 39,
1307
+ 65,
1308
+ 39,
1309
+ 71,
1310
+ 30,
1311
+ 71,
1312
+ 30,
1313
+ 73,
1314
+ 26,
1315
+ 78,
1316
+ 26,
1317
+ 79,
1318
+ 26,
1319
+ 79,
1320
+ 24,
1321
+ 82,
1322
+ 23,
1323
+ 86,
1324
+ 21,
1325
+ 89,
1326
+ 19,
1327
+ 90,
1328
+ 18,
1329
+ 91,
1330
+ 12,
1331
+ 96,
1332
+ 7,
1333
+ 99,
1334
+ 5,
1335
+ 100
1336
+ ],
1337
+ "output": [
1338
+ 2,
1339
+ 100,
1340
+ 5,
1341
+ 97,
1342
+ 7,
1343
+ 93,
1344
+ 11,
1345
+ 91,
1346
+ 16,
1347
+ 88,
1348
+ 19,
1349
+ 86,
1350
+ 21,
1351
+ 86,
1352
+ 22,
1353
+ 84,
1354
+ 23,
1355
+ 82,
1356
+ 23,
1357
+ 79,
1358
+ 24,
1359
+ 78,
1360
+ 24,
1361
+ 75,
1362
+ 25,
1363
+ 73,
1364
+ 28,
1365
+ 70,
1366
+ 31,
1367
+ 70,
1368
+ 31,
1369
+ 66,
1370
+ 38,
1371
+ 65,
1372
+ 42,
1373
+ 65,
1374
+ 44,
1375
+ 64,
1376
+ 46,
1377
+ 61,
1378
+ 57,
1379
+ 59,
1380
+ 57,
1381
+ 56,
1382
+ 57,
1383
+ 56,
1384
+ 57,
1385
+ 54,
1386
+ 57,
1387
+ 46,
1388
+ 61,
1389
+ 46,
1390
+ 64,
1391
+ 45,
1392
+ 64,
1393
+ 43,
1394
+ 64,
1395
+ 39,
1396
+ 65,
1397
+ 39,
1398
+ 71,
1399
+ 30,
1400
+ 71,
1401
+ 30,
1402
+ 73,
1403
+ 26,
1404
+ 78,
1405
+ 26,
1406
+ 79,
1407
+ 26,
1408
+ 79,
1409
+ 24,
1410
+ 82,
1411
+ 23,
1412
+ 86,
1413
+ 21,
1414
+ 89,
1415
+ 19,
1416
+ 90,
1417
+ 18,
1418
+ 91,
1419
+ 12,
1420
+ 96,
1421
+ 7,
1422
+ 99,
1423
+ 5,
1424
+ 100
1425
+ ]
1426
+ }
1427
+ ],
1428
+ "haskell_template": "sortEvenOdd :: [Int] -> [Int]\nsortEvenOdd nums ",
1429
+ "ocaml_template": "let sortEvenOdd (nums: int list) : int list = ",
1430
+ "scala_template": "def sortEvenOdd(nums: List[Int]): List[Int] = { \n \n}",
1431
+ "java_template": "public static List<Integer> sortEvenOdd(List<Integer> nums) {\n\n}",
1432
+ "python_template": "class Solution(object):\n def sortEvenOdd(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: List[int]\n \"\"\"\n "
1433
+ }
sort_even_and_odd_indices_independently/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;3;4;1] (sortEvenOdd [4;1;2;3])
12
+
13
+ let test2 _ = assert_equal [2;1] (sortEvenOdd [2;1])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for sortEvenOdd" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
sort_even_and_odd_indices_independently/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.sortEvenOdd(List(4,1,2,3)), List(2,3,4,1))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.sortEvenOdd(List(2,1)), List(2,1))
10
+ }
11
+
12
+ }
sort_matrix_by_diagonals/haskell_tests/Main.hs ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ sortMatrix :: [[Int]] -> [[Int]]
7
+ sortMatrix grid = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (sortMatrix [[1,7,3],[9,8,2],[4,5,6]])," [[8,2,3],[9,6,7],[4,5,1]] (sortMatrix [[1,7,3],[9,8,2],[4,5,6]]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (sortMatrix [[0,1],[1,2]])," [[2,1],[1,0]] (sortMatrix [[0,1],[1,2]]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (sortMatrix [[1]])," [[1]] (sortMatrix [[1]]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (sortMatrix [[73413, 89675], [64042, 3426]])," [[73413,89675],[64042,3426]] (sortMatrix [[73413, 89675], [64042, 3426]]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (sortMatrix [[93534, ( -60538), 1100, ( -29080)], [73904, 73681, ( -42006), 58036], [-54576, 43994, ( -44130), ( -9191)], [35790, ( -98159), ( -43670), ( -71219)]])," [[93534,(-60538),1100,(-29080)],[73904,73681,(-42006),58036],[-54576,43994,(-44130),(-9191)],[35790,(-98159),(-43670),(-71219)]] (sortMatrix [[93534, -60538, 1100, -29080], [73904, 73681, -42006, 58036], [-54576, 43994, -44130, -9191], [35790, -98159, -43670, -71219]]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (sortMatrix [[59508, ( -30375), 53549], [76794, ( -45364), 68655], [59076, ( -95778), ( -72798)]])," [[59508,(-30375),53549],[76794,(-45364),68655],[59076,(-95778),(-72798)]] (sortMatrix [[59508, -30375, 53549], [76794, -45364, 68655], [59076, -95778, -72798]]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (sortMatrix [[70237, ( -28097), ( -75510), ( -93714), ( -13815), ( -81959), ( -59992), ( -43975), ( -70863)], [40288, 50377, ( -15278), ( -54865), ( -78871), 38194, ( -64139), ( -23739), 83299], [75198, 26853, 45303, 17073, ( -52554), ( -69846), 41075, ( -10375), 61633], [71858, 25443, ( -12504), 17141, 46172, ( -23439), 16688, 46570, 24044], [59184, 60566, 13801, ( -28186), ( -2540), 59190, ( -3452), 81433, 67105], [90462, 37330, 57191, ( -30681), ( -44432), ( -22472), 59534, 27280, 83274], [99727, 15152, ( -37289), 36698, ( -39528), ( -47895), ( -50758), 75176, 62571], [83565, ( -16059), ( -17953), ( -40686), 35575, ( -41645), ( -74717), ( -80703), 78122], [12632, 65938, ( -48947), ( -75351), ( -84100), ( -18388), ( -96082), ( -97690), ( -92412)]])," [[70237,(-28097),(-75510),(-93714),(-13815),(-81959),(-59992),(-43975),(-70863)],[40288,50377,(-15278),(-54865),(-78871),38194,(-64139),(-23739),83299],[75198,26853,45303,17073,(-52554),(-69846),41075,(-10375),61633],[71858,25443,(-12504),17141,46172,(-23439),16688,46570,24044],[59184,60566,13801,(-28186),(-2540),59190,(-3452),81433,67105],[90462,37330,57191,(-30681),(-44432),(-22472),59534,27280,83274],[99727,15152,(-37289),36698,(-39528),(-47895),(-50758),75176,62571],[83565,(-16059),(-17953),(-40686),35575,(-41645),(-74717),(-80703),78122],[12632,65938,(-48947),(-75351),(-84100),(-18388),(-96082),(-97690),(-92412)]] (sortMatrix [[70237, -28097, -75510, -93714, -13815, -81959, -59992, -43975, -70863], [40288, 50377, -15278, -54865, -78871, 38194, -64139, -23739, 83299], [75198, 26853, 45303, 17073, -52554, -69846, 41075, -10375, 61633], [71858, 25443, -12504, 17141, 46172, -23439, 16688, 46570, 24044], [59184, 60566, 13801, -28186, -2540, 59190, -3452, 81433, 67105], [90462, 37330, 57191, -30681, -44432, -22472, 59534, 27280, 83274], [99727, 15152, -37289, 36698, -39528, -47895, -50758, 75176, 62571], [83565, -16059, -17953, -40686, 35575, -41645, -74717, -80703, 78122], [12632, 65938, -48947, -75351, -84100, -18388, -96082, -97690, -92412]]))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (sortMatrix [[93680, ( -89587), ( -96793), ( -88056), ( -67363), ( -57242), ( -67539), ( -78121), ( -55829), ( -57391)], [70507, 28181, ( -65217), ( -76332), ( -42429), ( -38150), ( -48555), ( -2009), ( -63212), 39636], [69116, 50346, 23408, ( -40122), ( -75329), 29472, ( -21407), ( -29091), ( -468), 29793], [64817, 39118, 38117, 4200, 31191, ( -62081), 42875, 4261, 43215, 1967], [73153, 49917, 23947, 32443, ( -25788), 51430, ( -30848), 66550, 62937, 91163], [48378, 66018, 37406, ( -4699), 21998, ( -41176), 78126, 19189, 79570, 81497], [-23104, 19536, 53987, 29462, ( -10253), 16954, ( -47341), 80533, 52244, 81496], [66168, ( -30888), ( -18525), 40048, 23718, ( -52041), ( -14933), ( -49448), 90366, 99859], [55807, 60419, ( -45089), ( -30668), 8678, ( -10026), ( -56978), ( -16041), ( -78687), 91900], [-31370, ( -47928), ( -12268), ( -84613), ( -76766), ( -42972), ( -74771), ( -88090), ( -58183), ( -79213)]])," [[93680,(-89587),(-96793),(-88056),(-67363),(-57242),(-67539),(-78121),(-55829),(-57391)],[70507,28181,(-65217),(-76332),(-42429),(-38150),(-48555),(-2009),(-63212),39636],[69116,50346,23408,(-40122),(-75329),29472,(-21407),(-29091),(-468),29793],[64817,39118,38117,4200,31191,(-62081),42875,4261,43215,1967],[73153,49917,23947,32443,(-25788),51430,(-30848),66550,62937,91163],[48378,66018,37406,(-4699),21998,(-41176),78126,19189,79570,81497],[-23104,19536,53987,29462,(-10253),16954,(-47341),80533,52244,81496],[66168,(-30888),(-18525),40048,23718,(-52041),(-14933),(-49448),90366,99859],[55807,60419,(-45089),(-30668),8678,(-10026),(-56978),(-16041),(-78687),91900],[-31370,(-47928),(-12268),(-84613),(-76766),(-42972),(-74771),(-88090),(-58183),(-79213)]] (sortMatrix [[93680, -89587, -96793, -88056, -67363, -57242, -67539, -78121, -55829, -57391], [70507, 28181, -65217, -76332, -42429, -38150, -48555, -2009, -63212, 39636], [69116, 50346, 23408, -40122, -75329, 29472, -21407, -29091, -468, 29793], [64817, 39118, 38117, 4200, 31191, -62081, 42875, 4261, 43215, 1967], [73153, 49917, 23947, 32443, -25788, 51430, -30848, 66550, 62937, 91163], [48378, 66018, 37406, -4699, 21998, -41176, 78126, 19189, 79570, 81497], [-23104, 19536, 53987, 29462, -10253, 16954, -47341, 80533, 52244, 81496], [66168, -30888, -18525, 40048, 23718, -52041, -14933, -49448, 90366, 99859], [55807, 60419, -45089, -30668, 8678, -10026, -56978, -16041, -78687, 91900], [-31370, -47928, -12268, -84613, -76766, -42972, -74771, -88090, -58183, -79213]]))
36
+
37
+
38
+ -- Grouping test cases
39
+ tests :: Test
40
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7]
41
+
42
+ -- Running the tests
43
+ main :: IO Counts
44
+ main = runTestTT tests
sort_matrix_by_diagonals/java_tests/Main.java ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(Arrays.asList(Arrays.asList(8,2,3),Arrays.asList(9,6,7),Arrays.asList(4,5,1)), sortMatrix(Arrays.asList(Arrays.asList(1,7,3),Arrays.asList(9,8,2),Arrays.asList(4,5,6))));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(Arrays.asList(Arrays.asList(2,1),Arrays.asList(1,0)), sortMatrix(Arrays.asList(Arrays.asList(0,1),Arrays.asList(1,2))));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(Arrays.asList(Arrays.asList(1)), sortMatrix(Arrays.asList(Arrays.asList(1))));
22
+ }
23
+
24
+ }
sort_matrix_by_diagonals/meta.json ADDED
@@ -0,0 +1,594 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3748,
3
+ "name": "sort_matrix_by_diagonals",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/sort-matrix-by-diagonals/",
6
+ "date": "2025-02-02 00:00:00",
7
+ "task_description": "You are given an `n x n` square matrix of integers `grid`. Return the matrix such that: The diagonals in the **bottom-left triangle** (including the middle diagonal) are sorted in **non-increasing order**. The diagonals in the **top-right triangle** are sorted in **non-decreasing order**. **Example 1:** **Input:** grid = [[1,7,3],[9,8,2],[4,5,6]] **Output:** [[8,2,3],[9,6,7],[4,5,1]] **Explanation:** The diagonals with a black arrow (bottom-left triangle) should be sorted in non-increasing order: `[1, 8, 6]` becomes `[8, 6, 1]`. `[9, 5]` and `[4]` remain unchanged. The diagonals with a blue arrow (top-right triangle) should be sorted in non-decreasing order: `[7, 2]` becomes `[2, 7]`. `[3]` remains unchanged. **Example 2:** **Input:** grid = [[0,1],[1,2]] **Output:** [[2,1],[1,0]] **Explanation:** The diagonals with a black arrow must be non-increasing, so `[0, 2]` is changed to `[2, 0]`. The other diagonals are already in the correct order. **Example 3:** **Input:** grid = [[1]] **Output:** [[1]] **Explanation:** Diagonals with exactly one element are already in order, so no changes are needed. **Constraints:** `grid.length == grid[i].length == n` `1 <= n <= 10` `-105 <= grid[i][j] <= 105`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "grid = [[1,7,3],[9,8,2],[4,5,6]]",
12
+ "output": "[[8,2,3],[9,6,7],[4,5,1]] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "grid = [[0,1],[1,2]]",
17
+ "output": "[[2,1],[1,0]] "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "grid = [[1]]",
22
+ "output": "[[1]] "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ [
29
+ 73413,
30
+ 89675
31
+ ],
32
+ [
33
+ 64042,
34
+ 3426
35
+ ]
36
+ ],
37
+ "output": [
38
+ [
39
+ 73413,
40
+ 89675
41
+ ],
42
+ [
43
+ 64042,
44
+ 3426
45
+ ]
46
+ ]
47
+ },
48
+ {
49
+ "input": [
50
+ [
51
+ 93534,
52
+ -60538,
53
+ 1100,
54
+ -29080
55
+ ],
56
+ [
57
+ 73904,
58
+ 73681,
59
+ -42006,
60
+ 58036
61
+ ],
62
+ [
63
+ -54576,
64
+ 43994,
65
+ -44130,
66
+ -9191
67
+ ],
68
+ [
69
+ 35790,
70
+ -98159,
71
+ -43670,
72
+ -71219
73
+ ]
74
+ ],
75
+ "output": [
76
+ [
77
+ 93534,
78
+ -60538,
79
+ 1100,
80
+ -29080
81
+ ],
82
+ [
83
+ 73904,
84
+ 73681,
85
+ -42006,
86
+ 58036
87
+ ],
88
+ [
89
+ -54576,
90
+ 43994,
91
+ -44130,
92
+ -9191
93
+ ],
94
+ [
95
+ 35790,
96
+ -98159,
97
+ -43670,
98
+ -71219
99
+ ]
100
+ ]
101
+ },
102
+ {
103
+ "input": [
104
+ [
105
+ 59508,
106
+ -30375,
107
+ 53549
108
+ ],
109
+ [
110
+ 76794,
111
+ -45364,
112
+ 68655
113
+ ],
114
+ [
115
+ 59076,
116
+ -95778,
117
+ -72798
118
+ ]
119
+ ],
120
+ "output": [
121
+ [
122
+ 59508,
123
+ -30375,
124
+ 53549
125
+ ],
126
+ [
127
+ 76794,
128
+ -45364,
129
+ 68655
130
+ ],
131
+ [
132
+ 59076,
133
+ -95778,
134
+ -72798
135
+ ]
136
+ ]
137
+ },
138
+ {
139
+ "input": [
140
+ [
141
+ 70237,
142
+ -28097,
143
+ -75510,
144
+ -93714,
145
+ -13815,
146
+ -81959,
147
+ -59992,
148
+ -43975,
149
+ -70863
150
+ ],
151
+ [
152
+ 40288,
153
+ 50377,
154
+ -15278,
155
+ -54865,
156
+ -78871,
157
+ 38194,
158
+ -64139,
159
+ -23739,
160
+ 83299
161
+ ],
162
+ [
163
+ 75198,
164
+ 26853,
165
+ 45303,
166
+ 17073,
167
+ -52554,
168
+ -69846,
169
+ 41075,
170
+ -10375,
171
+ 61633
172
+ ],
173
+ [
174
+ 71858,
175
+ 25443,
176
+ -12504,
177
+ 17141,
178
+ 46172,
179
+ -23439,
180
+ 16688,
181
+ 46570,
182
+ 24044
183
+ ],
184
+ [
185
+ 59184,
186
+ 60566,
187
+ 13801,
188
+ -28186,
189
+ -2540,
190
+ 59190,
191
+ -3452,
192
+ 81433,
193
+ 67105
194
+ ],
195
+ [
196
+ 90462,
197
+ 37330,
198
+ 57191,
199
+ -30681,
200
+ -44432,
201
+ -22472,
202
+ 59534,
203
+ 27280,
204
+ 83274
205
+ ],
206
+ [
207
+ 99727,
208
+ 15152,
209
+ -37289,
210
+ 36698,
211
+ -39528,
212
+ -47895,
213
+ -50758,
214
+ 75176,
215
+ 62571
216
+ ],
217
+ [
218
+ 83565,
219
+ -16059,
220
+ -17953,
221
+ -40686,
222
+ 35575,
223
+ -41645,
224
+ -74717,
225
+ -80703,
226
+ 78122
227
+ ],
228
+ [
229
+ 12632,
230
+ 65938,
231
+ -48947,
232
+ -75351,
233
+ -84100,
234
+ -18388,
235
+ -96082,
236
+ -97690,
237
+ -92412
238
+ ]
239
+ ],
240
+ "output": [
241
+ [
242
+ 70237,
243
+ -28097,
244
+ -75510,
245
+ -93714,
246
+ -13815,
247
+ -81959,
248
+ -59992,
249
+ -43975,
250
+ -70863
251
+ ],
252
+ [
253
+ 40288,
254
+ 50377,
255
+ -15278,
256
+ -54865,
257
+ -78871,
258
+ 38194,
259
+ -64139,
260
+ -23739,
261
+ 83299
262
+ ],
263
+ [
264
+ 75198,
265
+ 26853,
266
+ 45303,
267
+ 17073,
268
+ -52554,
269
+ -69846,
270
+ 41075,
271
+ -10375,
272
+ 61633
273
+ ],
274
+ [
275
+ 71858,
276
+ 25443,
277
+ -12504,
278
+ 17141,
279
+ 46172,
280
+ -23439,
281
+ 16688,
282
+ 46570,
283
+ 24044
284
+ ],
285
+ [
286
+ 59184,
287
+ 60566,
288
+ 13801,
289
+ -28186,
290
+ -2540,
291
+ 59190,
292
+ -3452,
293
+ 81433,
294
+ 67105
295
+ ],
296
+ [
297
+ 90462,
298
+ 37330,
299
+ 57191,
300
+ -30681,
301
+ -44432,
302
+ -22472,
303
+ 59534,
304
+ 27280,
305
+ 83274
306
+ ],
307
+ [
308
+ 99727,
309
+ 15152,
310
+ -37289,
311
+ 36698,
312
+ -39528,
313
+ -47895,
314
+ -50758,
315
+ 75176,
316
+ 62571
317
+ ],
318
+ [
319
+ 83565,
320
+ -16059,
321
+ -17953,
322
+ -40686,
323
+ 35575,
324
+ -41645,
325
+ -74717,
326
+ -80703,
327
+ 78122
328
+ ],
329
+ [
330
+ 12632,
331
+ 65938,
332
+ -48947,
333
+ -75351,
334
+ -84100,
335
+ -18388,
336
+ -96082,
337
+ -97690,
338
+ -92412
339
+ ]
340
+ ]
341
+ },
342
+ {
343
+ "input": [
344
+ [
345
+ 93680,
346
+ -89587,
347
+ -96793,
348
+ -88056,
349
+ -67363,
350
+ -57242,
351
+ -67539,
352
+ -78121,
353
+ -55829,
354
+ -57391
355
+ ],
356
+ [
357
+ 70507,
358
+ 28181,
359
+ -65217,
360
+ -76332,
361
+ -42429,
362
+ -38150,
363
+ -48555,
364
+ -2009,
365
+ -63212,
366
+ 39636
367
+ ],
368
+ [
369
+ 69116,
370
+ 50346,
371
+ 23408,
372
+ -40122,
373
+ -75329,
374
+ 29472,
375
+ -21407,
376
+ -29091,
377
+ -468,
378
+ 29793
379
+ ],
380
+ [
381
+ 64817,
382
+ 39118,
383
+ 38117,
384
+ 4200,
385
+ 31191,
386
+ -62081,
387
+ 42875,
388
+ 4261,
389
+ 43215,
390
+ 1967
391
+ ],
392
+ [
393
+ 73153,
394
+ 49917,
395
+ 23947,
396
+ 32443,
397
+ -25788,
398
+ 51430,
399
+ -30848,
400
+ 66550,
401
+ 62937,
402
+ 91163
403
+ ],
404
+ [
405
+ 48378,
406
+ 66018,
407
+ 37406,
408
+ -4699,
409
+ 21998,
410
+ -41176,
411
+ 78126,
412
+ 19189,
413
+ 79570,
414
+ 81497
415
+ ],
416
+ [
417
+ -23104,
418
+ 19536,
419
+ 53987,
420
+ 29462,
421
+ -10253,
422
+ 16954,
423
+ -47341,
424
+ 80533,
425
+ 52244,
426
+ 81496
427
+ ],
428
+ [
429
+ 66168,
430
+ -30888,
431
+ -18525,
432
+ 40048,
433
+ 23718,
434
+ -52041,
435
+ -14933,
436
+ -49448,
437
+ 90366,
438
+ 99859
439
+ ],
440
+ [
441
+ 55807,
442
+ 60419,
443
+ -45089,
444
+ -30668,
445
+ 8678,
446
+ -10026,
447
+ -56978,
448
+ -16041,
449
+ -78687,
450
+ 91900
451
+ ],
452
+ [
453
+ -31370,
454
+ -47928,
455
+ -12268,
456
+ -84613,
457
+ -76766,
458
+ -42972,
459
+ -74771,
460
+ -88090,
461
+ -58183,
462
+ -79213
463
+ ]
464
+ ],
465
+ "output": [
466
+ [
467
+ 93680,
468
+ -89587,
469
+ -96793,
470
+ -88056,
471
+ -67363,
472
+ -57242,
473
+ -67539,
474
+ -78121,
475
+ -55829,
476
+ -57391
477
+ ],
478
+ [
479
+ 70507,
480
+ 28181,
481
+ -65217,
482
+ -76332,
483
+ -42429,
484
+ -38150,
485
+ -48555,
486
+ -2009,
487
+ -63212,
488
+ 39636
489
+ ],
490
+ [
491
+ 69116,
492
+ 50346,
493
+ 23408,
494
+ -40122,
495
+ -75329,
496
+ 29472,
497
+ -21407,
498
+ -29091,
499
+ -468,
500
+ 29793
501
+ ],
502
+ [
503
+ 64817,
504
+ 39118,
505
+ 38117,
506
+ 4200,
507
+ 31191,
508
+ -62081,
509
+ 42875,
510
+ 4261,
511
+ 43215,
512
+ 1967
513
+ ],
514
+ [
515
+ 73153,
516
+ 49917,
517
+ 23947,
518
+ 32443,
519
+ -25788,
520
+ 51430,
521
+ -30848,
522
+ 66550,
523
+ 62937,
524
+ 91163
525
+ ],
526
+ [
527
+ 48378,
528
+ 66018,
529
+ 37406,
530
+ -4699,
531
+ 21998,
532
+ -41176,
533
+ 78126,
534
+ 19189,
535
+ 79570,
536
+ 81497
537
+ ],
538
+ [
539
+ -23104,
540
+ 19536,
541
+ 53987,
542
+ 29462,
543
+ -10253,
544
+ 16954,
545
+ -47341,
546
+ 80533,
547
+ 52244,
548
+ 81496
549
+ ],
550
+ [
551
+ 66168,
552
+ -30888,
553
+ -18525,
554
+ 40048,
555
+ 23718,
556
+ -52041,
557
+ -14933,
558
+ -49448,
559
+ 90366,
560
+ 99859
561
+ ],
562
+ [
563
+ 55807,
564
+ 60419,
565
+ -45089,
566
+ -30668,
567
+ 8678,
568
+ -10026,
569
+ -56978,
570
+ -16041,
571
+ -78687,
572
+ 91900
573
+ ],
574
+ [
575
+ -31370,
576
+ -47928,
577
+ -12268,
578
+ -84613,
579
+ -76766,
580
+ -42972,
581
+ -74771,
582
+ -88090,
583
+ -58183,
584
+ -79213
585
+ ]
586
+ ]
587
+ }
588
+ ],
589
+ "haskell_template": "sortMatrix :: [[Int]] -> [[Int]]\nsortMatrix grid ",
590
+ "ocaml_template": "let sortMatrix (grid: int list list) : int list list = ",
591
+ "scala_template": "def sortMatrix(grid: List[List[Int]]): List[List[Int]] = { \n \n}",
592
+ "java_template": "class Solution {\n public int[][] sortMatrix(int[][] grid) {\n \n }\n}",
593
+ "python_template": "class Solution(object):\n def sortMatrix(self, grid):\n \"\"\"\n :type grid: List[List[int]]\n :rtype: List[List[int]]\n \"\"\"\n "
594
+ }
sort_matrix_by_diagonals/ocaml_tests/main.ml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let sortMatrix (grid: int list list) : int list list = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal [[8;2;3];[9;6;7];[4;5;1]] (sortMatrix [[1;7;3];[9;8;2];[4;5;6]])
13
+
14
+ let test2 _ = assert_equal [[2;1];[1;0]] (sortMatrix [[0;1];[1;2]])
15
+
16
+ let test3 _ = assert_equal [[1]] (sortMatrix [[1]])
17
+
18
+ let test4 _ = assert_equal [[1]] (sortMatrix [[73413; 89675]; [64042; 3426]])
19
+
20
+ let test5 _ = assert_equal [[1]] (sortMatrix [[93534; -60538; 1100; -29080]; [73904; 73681; -42006; 58036]; [-54576; 43994; -44130; -9191]; [35790; -98159; -43670; -71219]])
21
+
22
+ let test6 _ = assert_equal [[1]] (sortMatrix [[59508; -30375; 53549]; [76794; -45364; 68655]; [59076; -95778; -72798]])
23
+
24
+ let test7 _ = assert_equal [[1]] (sortMatrix [[70237; -28097; -75510; -93714; -13815; -81959; -59992; -43975; -70863]; [40288; 50377; -15278; -54865; -78871; 38194; -64139; -23739; 83299]; [75198; 26853; 45303; 17073; -52554; -69846; 41075; -10375; 61633]; [71858; 25443; -12504; 17141; 46172; -23439; 16688; 46570; 24044]; [59184; 60566; 13801; -28186; -2540; 59190; -3452; 81433; 67105]; [90462; 37330; 57191; -30681; -44432; -22472; 59534; 27280; 83274]; [99727; 15152; -37289; 36698; -39528; -47895; -50758; 75176; 62571]; [83565; -16059; -17953; -40686; 35575; -41645; -74717; -80703; 78122]; [12632; 65938; -48947; -75351; -84100; -18388; -96082; -97690; -92412]])
25
+
26
+ let test8 _ = assert_equal [[1]] (sortMatrix [[93680; -89587; -96793; -88056; -67363; -57242; -67539; -78121; -55829; -57391]; [70507; 28181; -65217; -76332; -42429; -38150; -48555; -2009; -63212; 39636]; [69116; 50346; 23408; -40122; -75329; 29472; -21407; -29091; -468; 29793]; [64817; 39118; 38117; 4200; 31191; -62081; 42875; 4261; 43215; 1967]; [73153; 49917; 23947; 32443; -25788; 51430; -30848; 66550; 62937; 91163]; [48378; 66018; 37406; -4699; 21998; -41176; 78126; 19189; 79570; 81497]; [-23104; 19536; 53987; 29462; -10253; 16954; -47341; 80533; 52244; 81496]; [66168; -30888; -18525; 40048; 23718; -52041; -14933; -49448; 90366; 99859]; [55807; 60419; -45089; -30668; 8678; -10026; -56978; -16041; -78687; 91900]; [-31370; -47928; -12268; -84613; -76766; -42972; -74771; -88090; -58183; -79213]])
27
+
28
+
29
+ (* Grouping test cases *)
30
+ let suite = "Test Suite for sortMatrix" >::: [
31
+
32
+ "test1" >:: test1;
33
+ "test2" >:: test2;
34
+ "test3" >:: test3;
35
+ "test4" >:: test4;
36
+ "test5" >:: test5;
37
+ "test6" >:: test6;
38
+ "test7" >:: test7;
39
+ "test8" >:: test8;
40
+ ]
41
+
42
+
43
+ (* Running the tests *)
44
+ let () = run_test_tt_main suite
45
+ end
sort_matrix_by_diagonals/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.sortMatrix(List(List(1,7,3),List(9,8,2),List(4,5,6))), List(List(8,2,3),List(9,6,7),List(4,5,1)))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.sortMatrix(List(List(0,1),List(1,2))), List(List(2,1),List(1,0)))
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.sortMatrix(List(List(1))), List(List(1)))
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.sortMatrix(List(73413, 89675),List(64042, 3426)), List(List(73413,89675),List(64042,3426)))
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.sortMatrix(List(93534, -60538, 1100, -29080),List(73904, 73681, -42006, 58036),List(-54576, 43994, -44130, -9191),List(35790, -98159, -43670, -71219)), List(List(93534,-60538,1100,-29080),List(73904,73681,-42006,58036),List(-54576,43994,-44130,-9191),List(35790,-98159,-43670,-71219)))
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.sortMatrix(List(59508, -30375, 53549),List(76794, -45364, 68655),List(59076, -95778, -72798)), List(List(59508,-30375,53549),List(76794,-45364,68655),List(59076,-95778,-72798)))
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.sortMatrix(List(70237, -28097, -75510, -93714, -13815, -81959, -59992, -43975, -70863),List(40288, 50377, -15278, -54865, -78871, 38194, -64139, -23739, 83299),List(75198, 26853, 45303, 17073, -52554, -69846, 41075, -10375, 61633),List(71858, 25443, -12504, 17141, 46172, -23439, 16688, 46570, 24044),List(59184, 60566, 13801, -28186, -2540, 59190, -3452, 81433, 67105),List(90462, 37330, 57191, -30681, -44432, -22472, 59534, 27280, 83274),List(99727, 15152, -37289, 36698, -39528, -47895, -50758, 75176, 62571),List(83565, -16059, -17953, -40686, 35575, -41645, -74717, -80703, 78122),List(12632, 65938, -48947, -75351, -84100, -18388, -96082, -97690, -92412)), List(List(70237,-28097,-75510,-93714,-13815,-81959,-59992,-43975,-70863),List(40288,50377,-15278,-54865,-78871,38194,-64139,-23739,83299),List(75198,26853,45303,17073,-52554,-69846,41075,-10375,61633),List(71858,25443,-12504,17141,46172,-23439,16688,46570,24044),List(59184,60566,13801,-28186,-2540,59190,-3452,81433,67105),List(90462,37330,57191,-30681,-44432,-22472,59534,27280,83274),List(99727,15152,-37289,36698,-39528,-47895,-50758,75176,62571),List(83565,-16059,-17953,-40686,35575,-41645,-74717,-80703,78122),List(12632,65938,-48947,-75351,-84100,-18388,-96082,-97690,-92412)))
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.sortMatrix(List(93680, -89587, -96793, -88056, -67363, -57242, -67539, -78121, -55829, -57391),List(70507, 28181, -65217, -76332, -42429, -38150, -48555, -2009, -63212, 39636),List(69116, 50346, 23408, -40122, -75329, 29472, -21407, -29091, -468, 29793),List(64817, 39118, 38117, 4200, 31191, -62081, 42875, 4261, 43215, 1967),List(73153, 49917, 23947, 32443, -25788, 51430, -30848, 66550, 62937, 91163),List(48378, 66018, 37406, -4699, 21998, -41176, 78126, 19189, 79570, 81497),List(-23104, 19536, 53987, 29462, -10253, 16954, -47341, 80533, 52244, 81496),List(66168, -30888, -18525, 40048, 23718, -52041, -14933, -49448, 90366, 99859),List(55807, 60419, -45089, -30668, 8678, -10026, -56978, -16041, -78687, 91900),List(-31370, -47928, -12268, -84613, -76766, -42972, -74771, -88090, -58183, -79213)), List(List(93680,-89587,-96793,-88056,-67363,-57242,-67539,-78121,-55829,-57391),List(70507,28181,-65217,-76332,-42429,-38150,-48555,-2009,-63212,39636),List(69116,50346,23408,-40122,-75329,29472,-21407,-29091,-468,29793),List(64817,39118,38117,4200,31191,-62081,42875,4261,43215,1967),List(73153,49917,23947,32443,-25788,51430,-30848,66550,62937,91163),List(48378,66018,37406,-4699,21998,-41176,78126,19189,79570,81497),List(-23104,19536,53987,29462,-10253,16954,-47341,80533,52244,81496),List(66168,-30888,-18525,40048,23718,-52041,-14933,-49448,90366,99859),List(55807,60419,-45089,-30668,8678,-10026,-56978,-16041,-78687,91900),List(-31370,-47928,-12268,-84613,-76766,-42972,-74771,-88090,-58183,-79213)))
34
+ }
35
+
36
+ }
sort_the_people/.DS_Store ADDED
Binary file (6.15 kB). View file
 
sort_the_people/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 (sortPeople [ \"Mary \", \"John \", \"Emma \"] [180,165,170])," ["Mary","Emma","John"] (sortPeople ["Mary","John","Emma"] [180,165,170]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (sortPeople [ \"Alice \", \"Bob \", \"Bob \"] [155,185,150])," ["Bob","Alice","Bob"] (sortPeople ["Alice","Bob","Bob"] [155,185,150]))
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
sort_the_people/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(new ArrayList<>(Arrays.asList("Mary","Emma","John")), sortPeople(new ArrayList<>(Arrays.asList("Mary","John","Emma")), new ArrayList<>(Arrays.asList(180,165,170))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList("Bob","Alice","Bob")), sortPeople(new ArrayList<>(Arrays.asList("Alice","Bob","Bob")), new ArrayList<>(Arrays.asList(155,185,150))));
19
+ }
20
+
21
+ }
sort_the_people/meta.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2502,
3
+ "name": "sort_the_people",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/sort-the-people/",
6
+ "date": "1663459200000",
7
+ "task_description": "You are given an array of strings `names`, and an array `heights` that consists of **distinct** positive integers. Both arrays are of length `n`. For each index `i`, `names[i]` and `heights[i]` denote the name and height of the `ith` person. Return `names`_ sorted in **descending** order by the people's heights_. **Example 1:** ``` **Input:** names = [\"Mary\",\"John\",\"Emma\"], heights = [180,165,170] **Output:** [\"Mary\",\"Emma\",\"John\"] **Explanation:** Mary is the tallest, followed by Emma and John. ``` **Example 2:** ``` **Input:** names = [\"Alice\",\"Bob\",\"Bob\"], heights = [155,185,150] **Output:** [\"Bob\",\"Alice\",\"Bob\"] **Explanation:** The first Bob is the tallest, followed by Alice and the second Bob. ``` **Constraints:** `n == names.length == heights.length` `1 <= n <= 103` `1 <= names[i].length <= 20` `1 <= heights[i] <= 105` `names[i]` consists of lower and upper case English letters. All the values of `heights` are distinct.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "names = [\"Mary\",\"John\",\"Emma\"], heights = [180,165,170]",
12
+ "output": "[\"Mary\",\"Emma\",\"John\"] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "names = [\"Alice\",\"Bob\",\"Bob\"], heights = [155,185,150]",
17
+ "output": "[\"Bob\",\"Alice\",\"Bob\"] "
18
+ }
19
+ ],
20
+ "private_test_cases": [],
21
+ "haskell_template": "sortPeople :: [String] -> [Int] -> [String]\nsortPeople names heights ",
22
+ "ocaml_template": "let sortPeople (names: string list) (heights: int list) : string list = ",
23
+ "scala_template": "def sortPeople(names: List[String],heights: List[Int]): List[String] = { \n \n}",
24
+ "java_template": "public static List<String> sortPeople(List<String> names, List<Integer> heights) {\n\n}",
25
+ "python_template": "class Solution(object):\n def sortPeople(self, names, heights):\n \"\"\"\n :type names: List[str]\n :type heights: List[int]\n :rtype: List[str]\n \"\"\"\n "
26
+ }
sort_the_people/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 ["Mary";"Emma";"John"] (sortPeople ["Mary";"John";"Emma"] [180;165;170])
12
+
13
+ let test2 _ = assert_equal ["Bob";"Alice";"Bob"] (sortPeople ["Alice";"Bob";"Bob"] [155;185;150])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for sortPeople" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
sort_the_people/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.sortPeople(List("Mary","John","Emma"),List(180,165,170)), List("Mary","Emma","John"))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.sortPeople(List("Alice","Bob","Bob"),List(155,185,150)), List("Bob","Alice","Bob"))
10
+ }
11
+
12
+ }
sort_the_students_by_their_kth_score/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
sort_the_students_by_their_kth_score/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(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(7,5,11,2)),new ArrayList<>(Arrays.asList(10,6,9,1)),new ArrayList<>(Arrays.asList(4,8,3,15)))), sortTheStudents(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(10,6,9,1)),new ArrayList<>(Arrays.asList(7,5,11,2)),new ArrayList<>(Arrays.asList(4,8,3,15)))), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(5,6)),new ArrayList<>(Arrays.asList(3,4)))), sortTheStudents(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(3,4)),new ArrayList<>(Arrays.asList(5,6)))), 0));
19
+ }
20
+
21
+ }
sort_the_students_by_their_kth_score/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
sort_the_students_by_their_kth_score/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
sort_the_students_by_their_kth_score/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
sort_vowels_in_a_string/.DS_Store ADDED
Binary file (6.15 kB). View file
 
sort_vowels_in_a_string/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 (sortVowels \"lEetcOde \")," "lEOtcede" (sortVowels "lEetcOde"))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (sortVowels \"lYmpH \")," "lYmpH" (sortVowels "lYmpH"))
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
sort_vowels_in_a_string/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("lEetcOde", sortVowels("lEetcOde"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals("lYmpH", sortVowels("lYmpH"));
19
+ }
20
+
21
+ }
sort_vowels_in_a_string/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
sort_vowels_in_a_string/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 "lEOtcede" (sortVowels "lEetcOde")
12
+
13
+ let test2 _ = assert_equal "lYmpH" (sortVowels "lYmpH")
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for sortVowels" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
sort_vowels_in_a_string/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.sortVowels("lEetcOde"), "lEOtcede")
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.sortVowels("lYmpH"), "lYmpH")
10
+ }
11
+
12
+ }
sorted_gcd_pair_queries/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
sorted_gcd_pair_queries/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(new ArrayList<>(Arrays.asList(1,2,2)), gcdValues(new ArrayList<>(Arrays.asList(2,3,4)), new ArrayList<>(Arrays.asList(0,2,2))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(4,2,1,1)), gcdValues(new ArrayList<>(Arrays.asList(4,4,2,1)), new ArrayList<>(Arrays.asList(5,3,1,0))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(new ArrayList<>(Arrays.asList(2,2)), gcdValues(new ArrayList<>(Arrays.asList(2,2)), new ArrayList<>(Arrays.asList(0,0))));
23
+ }
24
+
25
+ }
sorted_gcd_pair_queries/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b15a77b1961456f5589cd2ff4aad67c079f690f3e49aff37db307b5f0f1ec93
3
+ size 40840946
sorted_gcd_pair_queries/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
sorted_gcd_pair_queries/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
sorting_three_groups/.DS_Store ADDED
Binary file (6.15 kB). View file
 
sorting_three_groups/haskell_tests/Main.hs ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 (minimumOperations [2,1,3,2,1])," 3 (minimumOperations [2,1,3,2,1]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimumOperations [1,3,2,1,3,3])," 2 (minimumOperations [1,3,2,1,3,3]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (minimumOperations [2,2,2,2,3,3])," 0 (minimumOperations [2,2,2,2,3,3]))
19
+
20
+
21
+ -- Grouping test cases
22
+ tests :: Test
23
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2]
24
+
25
+ -- Running the tests
26
+ main :: IO Counts
27
+ main = runTestTT tests