1092. To Buy or Not to Buy (20) simple

简介: #include using namespace std;int main(int argc, const char * argv[]) { // insert code here.
 
 
#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    string s0, s;
    cin >> s0 >> s;
    int cnt = 0;
    
    for (int i = 0; i < s.size(); i++) {
        int flag = 1;
        for (int j = 0; j < s0.size(); j++) {
            if (s[i] == s0[j]) {
                s0[j] = '-';
                flag = 0;
                break;
            }
        }
        if (flag) {
            cnt++;
        }
    }
    if (cnt) {
        cout << "No " << cnt << endl;
    }else{
        cout << "Yes " << s0.size() - s.size() << endl;
    }
    
    return 0;
}

目录
相关文章
|
算法
LeetCode 121. Best Time to Buy and Sell Stock
给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 如果您最多只允许完成一笔交易(即买入和卖出一支股票),设计一个算法来计算你所能获取的最大利润。
78 0
LeetCode 121. Best Time to Buy and Sell Stock
|
算法
LeetCode 123. Best Time to Buy and Sell Stock III
给定一个数组,它的第 i 个元素是一支给定的股票在第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你最多可以完成 两笔 交易。 注意: 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。
98 0
LeetCode 123. Best Time to Buy and Sell Stock III
|
算法
LeetCode 188. Best Time to Buy and Sell Stock IV
给定一个数组,它的第 i 个元素是一支给定的股票在第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你最多可以完成 k 笔交易。
81 0
LeetCode 188. Best Time to Buy and Sell Stock IV
Buy a Shovel
Buy a Shovel
99 0
Buy a Shovel
Leetcode-Easy 121. Best Time to Buy and Sell Stock
Leetcode-Easy 121. Best Time to Buy and Sell Stock
123 0
Leetcode-Easy 121. Best Time to Buy and Sell Stock
【1092】To Buy or Not to Buy (20 分)
【1092】To Buy or Not to Buy (20 分) 【1092】To Buy or Not to Buy (20 分)
96 0
【1090】Highest Price in Supply Chain (25 分)
【1090】Highest Price in Supply Chain (25 分) 【1090】Highest Price in Supply Chain (25 分)
100 0
【1106】Lowest Price in Supply Chain (25 分)
【1106】Lowest Price in Supply Chain (25 分) 【1106】Lowest Price in Supply Chain (25 分)
94 0