problemscpp
A collection of my answers to algorithm problems in c++.
| 函数
leetcode::minimum_swaps_to_group_all_1s_together_ii 命名空间参考

LeetCode 5977. 最少交换次数来组合所有的 1 II 更多...

class  Solution
 

函数

 TEST (minimum_swaps_to_group_all_1s_together_ii, case1)
 
 TEST (minimum_swaps_to_group_all_1s_together_ii, case2)
 
 TEST (minimum_swaps_to_group_all_1s_together_ii, case3)
 
 TEST (minimum_swaps_to_group_all_1s_together_ii, case4)
 

详细描述

LeetCode 5977. 最少交换次数来组合所有的 1 II

函数说明

◆ TEST() [1/4]

leetcode::minimum_swaps_to_group_all_1s_together_ii::TEST ( minimum_swaps_to_group_all_1s_together_ii  ,
case1   
)

在文件 leetcode_test.cpp371 行定义.

371 {
372 int input[] = {0, 1, 0, 1, 1, 0, 0};
373 auto vec = vector(begin(input), end(input));
374 ASSERT_EQ(1, Solution::minSwaps(vec));
375 }
int vec[100010]
Definition: pat.cpp:5095

引用了 leetcode::minimum_swaps_to_group_all_1s_together_ii::Solution::minSwaps() , 以及 pat::a::a7_2::vec.

◆ TEST() [2/4]

leetcode::minimum_swaps_to_group_all_1s_together_ii::TEST ( minimum_swaps_to_group_all_1s_together_ii  ,
case2   
)

在文件 leetcode_test.cpp377 行定义.

377 {
378 int input[] = {0, 1, 1, 1, 0, 0, 1, 1, 0};
379 auto vec = vector(begin(input), end(input));
380 ASSERT_EQ(2, Solution::minSwaps(vec));
381 }

引用了 leetcode::minimum_swaps_to_group_all_1s_together_ii::Solution::minSwaps() , 以及 pat::a::a7_2::vec.

◆ TEST() [3/4]

leetcode::minimum_swaps_to_group_all_1s_together_ii::TEST ( minimum_swaps_to_group_all_1s_together_ii  ,
case3   
)

在文件 leetcode_test.cpp383 行定义.

383 {
384 int input[] = {1, 1, 0, 0, 1};
385 auto vec = vector(begin(input), end(input));
386 ASSERT_EQ(0, Solution::minSwaps(vec));
387 }

引用了 leetcode::minimum_swaps_to_group_all_1s_together_ii::Solution::minSwaps() , 以及 pat::a::a7_2::vec.

◆ TEST() [4/4]

leetcode::minimum_swaps_to_group_all_1s_together_ii::TEST ( minimum_swaps_to_group_all_1s_together_ii  ,
case4   
)

在文件 leetcode_test.cpp389 行定义.

389 {
390 int input[] = {1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0,
391 1, 0, 0};
392 auto vec = vector(begin(input), end(input));
393 ASSERT_EQ(7, Solution::minSwaps(vec));
394 }

引用了 leetcode::minimum_swaps_to_group_all_1s_together_ii::Solution::minSwaps() , 以及 pat::a::a7_2::vec.