problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::minimum_moves_to_reach_target_score::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static int minMoves (int target, int maxDoubles)
 

详细描述

在文件 leetcode.h484 行定义.

成员函数说明

◆ minMoves()

int leetcode::minimum_moves_to_reach_target_score::Solution::minMoves ( int  target,
int  maxDoubles 
)
static

在文件 leetcode.cpp1067 行定义.

1067 {
1068 int count = 0;
1069 while(target != 1) {
1070 if(maxDoubles == 0) {
1071 return count + target - 1;
1072 }
1073 if(target % 2 == 0 && maxDoubles != 0) {
1074 target /= 2;
1075 maxDoubles--;
1076 } else {
1077 target--;
1078 }
1079 count++;
1080 }
1081 return count;
1082 }

被这些函数引用 leetcode::minimum_moves_to_reach_target_score::TEST().


该类的文档由以下文件生成: