389. Find the Difference
来源:互联网 发布:最好的win10优化工具 编辑:程序博客网 时间:2024/06/14 21:36
问题: Given two strings s and t which consist of only lowercase letters.
String t is generated by random shuffling string s and then add one more letter at a random position.
Find the letter that was added in t.
Example:Input:s = "abcd"t = "abcde"Output:eExplanation:'e' is the letter that was added.
解题思路:在t数组中查找有一样的字母,将它改为大写,最后剩下的小写字母就是要查找的字符。
解题思路:用长度为26的数组count来记录字母相对应的出现次数,s数组字符就在相应的位置加一,t数组字符就在相应的位置减一,最后count不为0的位置转换成字符就是所要查找的字符。
解题思路:用一个变量ans来统计数组s的异或结果,再与t数组来异或,出现两次的字符就会为零,最后ans剩下的就是另外添加的字符。
阅读全文
0 0
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference*
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- 389. Find the Difference
- CentOS7,MySQL主从配置和读写分离
- libphenom 学习笔记
- string+模拟——小A和小C
- 异步编程中的最佳做法
- Visual Studio 2012 创建一个控制台应用程序 01
- 389. Find the Difference
- COMPUTE 和 GROUP BY
- Crossword Answers 模拟 字符串
- opencv 霍夫变换检测直线中pt1、pt2点的确定
- C语言学习内容总结 2017/10/17
- Go, 互联网时代的C语言
- 洛谷 1514 引水入城(记忆化搜索+DP)
- 今日收获
- 失匹配负波(Mismatch Negativity, MMN)