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

#include <leetcode.h>

静态 Public 成员函数

static int minSteps (const string &s, const string &t)
 

详细描述

在文件 leetcode.h1389 行定义.

成员函数说明

◆ minSteps()

int leetcode::minimum_number_of_steps_to_make_two_strings_anagram_ii::Solution::minSteps ( const string &  s,
const string &  t 
)
static

在文件 leetcode.cpp3595 行定义.

3595 {
3596 int ans = 0;
3597 int s_num[26] = {};
3598 int t_num[26] = {};
3599 for(const char ch: s) {
3600 s_num[ch - 'a']++;
3601 }
3602 for(const char ch: t) {
3603 t_num[ch - 'a']++;
3604 }
3605 for(int i = 0; i < 26; i++) {
3606 ans += abs(s_num[i] - t_num[i]);
3607 }
3608 return ans;
3609 }

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


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