389. Find the Difference
一开始没看见shuffle...觉得同时遍历不就完事了。。
和那个所有数字出现2,有一个出现3次还是什么的一样,CHAR可以完美和INT相互切换。
public class Solution
{
public char findTheDifference(String s, String t)
{
int res = 0;
for(int i = 0; i < s.length();i++)
{
res ^= s.charAt(i);
}
for(int i = 0; i < t.length();i++)
{
res ^= t.charAt(i);
}
return (char)res;
}
}
389. Find the Difference的更多相关文章
- LeetCode 389. Find the Difference
Given two strings s and t which consist of only lowercase letters. String t is generated by random s ...
- LeetCode之389. Find the Difference
-------------------------------------------------- 先计算每个字母的出现次数然后减去,最后剩下的那一个就是后来添加的了. AC代码: public c ...
- 【LeetCode】389 Find the Difference(java)
原题 Given two strings s and t which consist of only lowercase letters. String t is generated by rando ...
- 9. leetcode 389. Find the Difference
Given two strings s and t which consist of only lowercase letters. String t is generated by random s ...
- LeetCode 389 Find the Difference 解题报告
题目要求 Given two strings s and t which consist of only lowercase letters. String t is generated by ran ...
- [LeetCode&Python] Problem 389. Find the Difference
Given two strings s and t which consist of only lowercase letters. String t is generated by random s ...
- LeetCode - 389. Find the Difference - 三种不同解法 - ( C++ ) - 解题报告
1.题目大意 Given two strings s and t which consist of only lowercase letters. String t is generated by r ...
- 389. Find the Difference 找出两个字符串中多余的一个字符
[抄题]: Given two strings s and t which consist of only lowercase letters. String t is generated by ra ...
- *389. Find the Difference (string + map(26)) read problems carefully
Given two strings s and t which consist of only lowercase letters. String t is generated by random s ...
随机推荐
- Ubuntu 13.04 配置Cocos2d-x记录
装备工作: 下载JavaJDK http://www.oracle.com/technetwork/java/javase/downloads/index.html 下载NDKhttp://deve ...
- 完全背包的变形POJ1252
话说今天做背包做到有点累了,题目是英文的--而且还很长,我看了好久(弱爆了). 题目大概的意思就是,有六种硬币,之后,求用这六种硬币最小数目支付1到100美分的平均值,以及最小数目中的最大值. 很容易 ...
- 机器视觉工具箱-Machine Vision Toolbox for Matlab
发现了一个机器视觉的Matlab工具箱,分享一下. 机器视觉工具箱(MVT的)规定,在机器视觉和基于视觉的控制有益的多种功能.这是一个有点折衷收集反映作者在光度学,摄影测量,色度学 方面的个人利益.它 ...
- POJ 1013 Counterfeit Dollar 集合上的位运算
Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are t ...
- ASP.NET MVC轻教程 Step By Step 11——数据注解
将验证规则写在Cotroller里不是一个好办法,这样会显得代码很啰嗦,更重要的是将业务逻辑写入Controller,使得Controller变得更“重”,不符合设计原则.更好的办法是使用验证注解属性 ...
- JSP特点
建立在servlet规范功能之上的动态网页技术. JSP文件在用户第一次请求时,会被编译成servlet,然后由servlet处理用户的请求.所以JSP可以看成运行时servlet. 1).将内容的生 ...
- Noah的学习笔记之Python篇:函数“可变长参数”
Noah的学习笔记之Python篇: 1.装饰器 2.函数“可变长参数” 3.命令行解析 注:本文全原创,作者:Noah Zhang (http://www.cnblogs.com/noahzn/) ...
- Android 开发环境搭建9传送帖)
---恢复内容开始--- 首先,得安装软件,感觉我所找到的一些课本上写的都比较简略,走过一些弯路后,决定按照这个百度经验来 Android安卓开发环境搭建详细教程 http://jingyan.bai ...
- 使用SeaJS实现模块化JavaScript开发
前言 SeaJS是一个遵循CommonJS规范的JavaScript模块加载框架,可以实现JavaScript的模块化开发及加载机制.与jQuery等JavaScript框架不同,SeaJS不会扩展封 ...
- iOS内存管理系列之一:对象所有权与引用计数
当一个所有者(owner,其本身可以是任何一个Objective-C对象)做了以下某个动作时,它拥有对一个对象的所有权(ownership): 1. 创建一个对象.包括使用任何名称中包含“alloc” ...