class Solution
{
public:
bool backspaceCompare(string S, string T)
{
int szs=S.size();
int szt=T.size();
int ends=,endt=;
for(int i=;i<szs;i++) //get the result string of S
{
if(S[i]=='#')
{
if(ends>)
ends--;
}
else
S[ends++]=S[i];
} for(int j=;j<szt;j++) //get the result string of T
{
if(T[j]=='#')
{
if(endt>)
endt--;
}
else
T[endt++]=T[j];
} if(ends!=endt)
return false;
for(int k=;k<ends;k++) //compare two result
{
if(S[k]!=T[k])
return false;
}
return true;
}
};

844. Backspace String Compare的更多相关文章

  1. 【Leetcode_easy】844. Backspace String Compare

    problem 844. Backspace String Compare solution1: class Solution { public: bool backspaceCompare(stri ...

  2. 844. Backspace String Compare判断删除后的结果是否相等

    [抄题]: Given two strings S and T, return if they are equal when both are typed into empty text editor ...

  3. [LeetCode] 844. Backspace String Compare 退格字符串比较

    Given two strings S and T, return if they are equal when both are typed into empty text editors. # m ...

  4. [LeetCode&Python] Problem 844. Backspace String Compare

    Given two strings S and T, return if they are equal when both are typed into empty text editors. # m ...

  5. 【LeetCode】844. Backspace String Compare 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字符串切片 栈 日期 题目地址:https://le ...

  6. [LeetCode] Backspace String Compare 退格字符串比较

    Given two strings S and T, return if they are equal when both are typed into empty text editors. # m ...

  7. [Swift]LeetCode844. 比较含退格的字符串 | Backspace String Compare

    Given two strings S and T, return if they are equal when both are typed into empty text editors. # m ...

  8. LeetCode - Backspace String Compare

    Given two strings S and T, return if they are equal when both are typed into empty text editors. # m ...

  9. leetcode-844 Backspace String Compare

    Given two strings S and T, return if they are equal when both are typed into empty text editors. # m ...

随机推荐

  1. Ant 初级入门

    一.Ant简介 Ant是一个Apache基金会下的跨平台的构件工具. 由于Ant是基于Java的,所以需要Java环境的支持,也就是配置好 JAVA_HOME 和 ANT_HOME 环境变量分别指向J ...

  2. CentOS Find命令

    find命令用来在指定目录下查找文件.任何位于参数之前的字符串都将被视为欲查找的目录名.如果使用该命令时,不设置任何参数,则find命令将在当前目录下查找子目录与文件.并且将查找到的子目录和文件全部进 ...

  3. 枚举+最短路 poj1062

    这里有个非常坑的地方,还有比酋长地位还更高的人,我也是看了论坛才知道... 在这里我把编号1看成终点,优惠价格看成相应的替代品编号到可替代品编号的权值,比如说有了2再加8000就到了1,那么2到1的弧 ...

  4. AD操作

    加泪滴 批量添加覆铜过孔(先铺铜以后,再批量添加过孔) 开槽   在KEPP—OUT层 部分区域 不敷铜 开窗  

  5. 将图片转换为Base64编码的字符串

    图片以文件的形式存在,可以在表单中使用. 也可以转换成Base64编码的字符串,从而在css.js中以字符串的形式使用图片.例如,在css中设置背景图片.在js中用ajax上传图片. <!DOC ...

  6. 【gRPC使用问题2】按照问题1操作生成出来的代码,import的proto内定义的message未生成出来

    1.问题 其实元数据proto里是有定义message,但是 这个message的定义是在另一个 proto文件内,被 api.proto导入,事实上 我是对 api.proto 进行命令行生成代码的 ...

  7. jquery分页插件精选

    1.最新的分页控件:Mricode.Pagination(推荐) https://github.com/mricle/Mricode.Pagination 2.Jquery Pagination Pl ...

  8. Oracle_SQL(2) 分组与聚合函数

    一.聚合函数1.定义:对表或视图的查询时,针对多行记录只返回一个值的函数.2.用途:用于select语句,HAVING条件二.5种聚合函数1.SUM(n) 对列求和 select sum(sal) f ...

  9. Oracle 修改字段顺序的两种方法

    分类: Oracle 如果要修改字段顺序,一般情况可以使用以下步骤: --(1)备份目标表数据 create table 临时表 as select * from 目标表; --(2)drop 目标表 ...

  10. 自定义标签tld的使用

    在JSP中使用标签是很平常的事情,在制作自定义标签时,通常都需要写tld文件来定义标签的各种属性,对应的Java类,前缀等等.标签与tld文件紧紧相连,那么,到底应该怎么放置tld文件?在web.xm ...