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 ...
随机推荐
- createjs 下雪 实例
demo: http://output.jsbin.com/davixatona <!DOCTYPE html> <html> <head> <meta c ...
- js 组件的写法
var Test1 = function(){ var name = ""; this.setName = function(username){ name = username; ...
- Setup FTP Server On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3
setsebool allow_ftpd_full_access onsetsebool -P ftp_home_dir on vsftpd (Very Secure File Transport P ...
- php 目录及文件操作
// bool is_dir(string $filename) 判断给定文件名是否是一个目录.// resource opendir(string $path[,resource $context] ...
- C#如何释放已经加载的图片 (转)
使用Image.FromFile取磁盘上的图片时,这个方法会锁定图片文件,而且会导致内存占用增大, 有几种方法解决: 一:将Image类转换成Bitmap类 System.Drawing.Image ...
- css3学习--css3动画详解二(3d效果)
一.设置3D场景 perspective:800 //浏览器到物体的距离(像素)perspective-origin:50% (x轴) 50% (y轴) //视点的位置 transf ...
- Mysql JDBC Url参数说明useUnicode=true&characterEncoding=UTF-8
MySQL的 JDBC URL 格式 for Connector/J 如下例: jdbc:mysql://[host][,failoverhost...][:port]/[database] » [ ...
- 练习2 J题 - 多项式求和
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Description 多项式 ...
- 源码编译基于Android平台的XBMC笔记
参考官方网站:https://github.com/xbmc/xbmc/blob/master/docs/README.android 1. 编译主机系统 Ubuntu (12.04) 64Bit ...
- DBA - 我的学习
DBA - 我的学习 1. df -k 检查oracle 分区硬盘使用情况 2. 检查alert_<SID名称>.log, alert日志文件,检查是否新增错误日志 3. 检查数据文件的状 ...