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

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

class  Solution
 

函数

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

详细描述

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

函数说明

◆ TEST() [1/4]

leetcode::minimum_swaps_to_group_all_1s_together::TEST ( minimum_swaps_to_group_all_1s_together  ,
case1   
)

在文件 leetcode_test.cpp4404 行定义.

4404 {
4405 vector data = {1, 0, 1, 0, 1};
4406 ASSERT_EQ(1, Solution::minSwaps(data));
4407 }

引用了 leetcode::minimum_swaps_to_group_all_1s_together::Solution::minSwaps().

◆ TEST() [2/4]

leetcode::minimum_swaps_to_group_all_1s_together::TEST ( minimum_swaps_to_group_all_1s_together  ,
case2   
)

在文件 leetcode_test.cpp4409 行定义.

4409 {
4410 vector data = {0, 0, 0, 1, 0};
4411 ASSERT_EQ(0, Solution::minSwaps(data));
4412 }

引用了 leetcode::minimum_swaps_to_group_all_1s_together::Solution::minSwaps().

◆ TEST() [3/4]

leetcode::minimum_swaps_to_group_all_1s_together::TEST ( minimum_swaps_to_group_all_1s_together  ,
case3   
)

在文件 leetcode_test.cpp4414 行定义.

4414 {
4415 vector data = {1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1};
4416 ASSERT_EQ(3, Solution::minSwaps(data));
4417 }

引用了 leetcode::minimum_swaps_to_group_all_1s_together::Solution::minSwaps().

◆ TEST() [4/4]

leetcode::minimum_swaps_to_group_all_1s_together::TEST ( minimum_swaps_to_group_all_1s_together  ,
case4   
)

在文件 leetcode_test.cpp4419 行定义.

4419 {
4420 vector data = {1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1};
4421 ASSERT_EQ(8, Solution::minSwaps(data));
4422 }

引用了 leetcode::minimum_swaps_to_group_all_1s_together::Solution::minSwaps().