leetcode 389 map iterator 的使用
class Solution {
public:
char findTheDifference(string s, string t) {
map<char,int>Map_Temp;
for(int i=;i<s.size();i++)
Map_Temp[s[i]-'a']++;
for(int i=;i<t.size();i++)
Map_Temp[t[i]-'a']--;
map<char,int>::iterator iter;
for(iter=Map_Temp.begin();iter!=Map_Temp.end();iter++)
if(iter->second)
return char(iter->first+'a');
return ;
}
};
leetcode 389 map iterator 的使用的更多相关文章
- Java容器类Collection,List,Set,Map.,Iterator,Collections工具类,Arrays工具类,Comparable
Java容器类Collection,List,Set,Map.,Iterator,Collections工具类,Arrays工具类,Comparable接口,泛型 Collection,List,Se ...
- [LeetCode] 900. RLE Iterator RLE迭代器
Write an iterator that iterates through a run-length encoded sequence. The iterator is initialized b ...
- [LeetCode] 281. Zigzag Iterator 之字形迭代器
Given two 1d vectors, implement an iterator to return their elements alternately. Example: Input: v1 ...
- [LeetCode] 284. Peeking Iterator 瞥一眼迭代器
Given an Iterator class interface with methods: next() and hasNext(), design and implement a Peeking ...
- [LeetCode#281] Zigzag Iterator
Problem: Given two 1d vectors, implement an iterator to return their elements alternately. For examp ...
- LeetCode 389——找不同
1. 题目 2. 解答 2.1. 方法一 将 s 和 t 转化为 Python 的列表,然后遍历列表 s 的元素,将它们从列表 t 中删除,最后列表 t 中会余下一个元素,即为所求. class So ...
- leetcode 900. RLE Iterator
Write an iterator that iterates through a run-length encoded sequence. The iterator is initialized b ...
- leetcode 349 map
只需要用map来标记1,今儿通过map的值来得到重叠的部分 class Solution { public: vector<int> intersection(vector<int& ...
- LeetCode 389. Find the Difference (找到不同)
Given two strings s and t which consist of only lowercase letters. String t is generated by random s ...
随机推荐
- 使用dotnet-dump 查找 .net core 3.0 占用CPU 100%的原因
公司的产品一直紧跟 .net core 3.0 preview 不断升级, 部署到 Linux 服务器后, 偶尔会出现某个进程CPU占用100%. 由于服务部署在云上, 不能使用远程调试; 在局域网内 ...
- read指令使用方法
read命令用于从标准输入中读取输入单行,并将读取的单行根据IFS变量分裂成多个字段,并将分割后的字段分别赋值给指定的变量列表var_name.第一个字段分配给第一个变量var_name1,第二个字段 ...
- JavaScript方法中this关键字使用注意
问题来源 本文是基于廖雪峰老师JavaScript课程中的方法一节以及阮一峰老师JavaScript 的 this 原理 所记. 首先,我们了解一下JavaScript中的方法:在一个对象中绑定函数, ...
- ECMAScript 6入门扩展笔记
字符串扩展 Unicode相关补充 引入"\u{xx}"来表示码点,之前只能表示\u0000-\uffff引入String.fromCodePoint()能正确读取大于uFFFF的 ...
- 使用python实现滑动验证码
首先安装一个需要用到的模块 pip install social-auth-app-django 安装完后在终端输入pip list会看到 social-auth-app-django social- ...
- 多进程的基本使用--multiprocessing 【转】
multiprocessing 如果你打算编写多进程的服务程序,Unix/Linux无疑是正确的选择.由于Windows没有fork调用,难道在Windows上无法用Python编写多进程的程序? 由 ...
- loj2173 「FJOI2016」建筑师
ref 真是道组合数学神题啊--第一次见第一类斯特林数-- #include <iostream> #include <cstdio> using namespace std; ...
- leetcode 【 Remove Duplicates from Sorted Array II 】python 实现
题目: Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For ex ...
- 04 JVM是如何执行方法调用的(上)
重载和重写 重载:同一个类中定义名字相同的方法,但是参数类型或者参数个数必须不同. 重载的方法在编译过程中就可完成识别.具体到每一个方法的调用,Java 编译器会根据所传入参数的生命类型来选取重载方法 ...
- hnust 聚宝盆
问题 A: 聚宝盆 时间限制: 1 Sec 内存限制: 128 MB提交: 663 解决: 282[提交][状态][讨论版] 题目描述 Grace是个善良的同学,他经常帮助同学解决问题.这天,他正 ...