leetcode389
来源:互联网 发布:通用编程器报价 编辑:程序博客网 时间:2024/06/06 02:32
1、Find the Difference
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:
e
Explanation:
‘e’ is the letter that was added.
class Solution {public: char findTheDifference(string s, string t) { int sum=0,sum1=0; for(int i=0;i<s.length();i++){ sum=sum+s[i]; } for(int i=0;i<t.length();i++){ sum1=sum1+t[i]; } return sum1-sum; }};
这个题类似与上一道题,把字母的问题转化成ASCII码加减~~简单高效~
0 0
- leetcode389
- LeetCode389. Find the Difference
- leetcode389: Find the Difference,
- Leetcode389. Find the Difference
- leetcode389. Find the Difference
- leetcode389. Find the Difference
- LeetCode389. Find the Difference简单
- leetcode389 Find the Difference java
- python--leetcode389. Find the Difference
- 算法系列(8)LeetCode389
- leetcode389[easy]---Find the Difference
- 【codeforces 750F】New Year and Finding Roots
- update优先级设置
- Android实现Canny算法
- 未能加载文件或程序集 Microsoft.ReportViewer.Common, Version=11.0.0.0
- R语言实战笔记--第十章 功效分析&样本量
- leetcode389
- VB.Net未能加载文件或程序集“XXX”或它的某一个依赖项。
- Caffe源码解析9: Caffe模型
- 使用eclipse创建之前没有创建的web.xml
- 有效学习的方法
- cart(分类与回归树)原理与实现
- mysql分区
- iOS CoreGraphics 框架介绍
- CSS学习