leetcode Bulls and Cows
来源:互联网 发布:食物减肥软件 编辑:程序博客网 时间:2024/06/06 10:02
class Solution { public: string getHint(string secret, string guess) { int sum1 = 0; int sum2 = 0; string se; string gu; for(int i = 0; i < secret.length(); i ++) { if(secret[i] == guess[i]) sum1 ++; else { se+=secret[i]; gu+=guess[i]; } } sort(se.begin(), se.end()); sort(gu.begin(), gu.end()); for(int i = 0, j = 0; i <se.length()&& j < se.length() ; ) { if(se[i] == gu[j]) { sum2++; i++;j++; } else if(se[i] < gu[j]) i++; else j++; } return to_string(sum1) + "A" + to_string(sum2) + "B"; } };
0 0
- [LeetCode]Bulls and Cows
- [LeetCode] Bulls and Cows
- LeetCode Bulls and Cows
- leetcode | Bulls and Cows
- LeetCode:Bulls and Cows
- LeetCode -- Bulls and Cows
- leetcode: Bulls and Cows
- [leetcode]Bulls and Cows
- Bulls and Cows-LeetCode
- [Leetcode]Bulls and Cows
- Leetcode: Bulls and Cows
- LeetCode Bulls and Cows
- 【Leetcode】bulls and cows
- LeetCode Bulls and Cows
- LeetCode: Bulls and Cows
- Leetcode - Bulls and Cows
- LeetCode:Bulls and Cows
- 【Leetcode】Bulls and Cows
- 233. Number of Digit One
- 设计模式--单例
- tolower字符串转换函数应用实例
- Confluence(四)--配置
- 润体
- leetcode Bulls and Cows
- 电话拨号器
- 伪类选择器
- Google推荐的图片加载库Glide介绍
- 吉他学习<2>和弦
- Android中<uses-sdk>属性和target属性分析
- 【毕业总结篇一】好用的c代码编辑工具与课本上学不到的冷门知识
- ListView的多布局
- 自定义view — Toggle开关