leetcode(87).389. Find the Difference
来源:互联网 发布:linux 输出文件夹大小 编辑:程序博客网 时间:2024/05/21 22:54
题意:
给定两个小写字母字符串,第二个字符串比第一个字符串多了一个字符,但是顺序可能打乱了。要求找出那个多出的字符。
现在的条件是,多了一个,顺序不一定,我们要最大限度的利用这个条件,就要想办法忽略顺序,所以要想一个办法,忽略具体的顺序来找出那个位置不一定的字符。既然位置要忽略,就考虑从内容入手。所以采用总值相减的办法。
public class Solution {public char findTheDifference(String s, String t) { int sums = 0; int sumt = 0; for(int i = 0; i < ars.length; i++){ sums += (int)s.charAt(i); } for(int i = 0; i < art.length; i++){ sumt += (int)t.charAt(i); } return (char)(sumt-sums); }}
0 0
- leetcode(87).389. Find the Difference
- LeetCode : 389. Find the Difference
- Leetcode 389. Find the Difference
- 【leetcode】389. Find the Difference
- Leetcode 389. Find the Difference
- LeetCode 389. Find the Difference
- LeetCode 389. Find the Difference
- [LeetCode]389. Find the Difference
- [LeetCode]--389. Find the Difference
- leetcode 389. Find the Difference
- LeetCode 389. Find the Difference
- LeetCode 389. Find the Difference
- leetcode 389. Find the Difference
- 389.[LeetCode]Find the Difference
- 【LeetCode】 389. Find the Difference
- [LeetCode]389. Find the Difference
- leetcode-389. Find the Difference
- Leetcode 389. Find the Difference
- 解读 OpenRegistryKey
- Java C++ 声明定义
- UNIX设计的思想。让每个程序只具有一项专门的能力,然后让它们合作
- 38. Count and Say徒手尝试#2(Done)
- [leetcode]287.Find the Duplicate Number
- leetcode(87).389. Find the Difference
- MySQL 操作总结(一)
- c语言里面log函数怎么用
- 读取联系人
- 大型网站技术架构
- java常用的第三方组件
- 深入理解ThreadLocal
- 设计模式之单例模式(java语言)
- LightOJ-1066-bfs