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. 从零开始写bootloader(2)

    下图是设置内核启动参数的存放图示,由于bootloader启动内核时,需要给内核传输一些启动参数,但是由于当bootloader把内核 启动之后,程序就跳转到内核中执行了,再也不会回到bootload ...

  2. RockerMQ介绍 及搭建双master模式

    一.RocketMQ介绍 1.1 简介 RocketMQ 是一款分布式.队列模型的消息中间件,具有以下特点: 能够保证严格的消息顺序 提供丰富的消息拉取模式 高效的订阅者水平扩展能力 实时的消息订阅机 ...

  3. 微信小程序编译包的获取与解压——在手机中获取小程序编译包wxapkg

    准备工作: 微信关注需要下载编译包的小程序,然后点进去看一下,微信就会自动下载相应的编译包到手机上了. 获取小程序编译包: 据说root手机可以直接在手机的文件管理中查找wxapkg文件,自己尝试了下 ...

  4. java中关于null的一些理解

    1.null是Java中的关键字,像public.static.final.它是大小写敏感的,你不能将null写成Null或NULL,编译器将不能识别它们然后报错. 2.null是任何引用类型的默认值 ...

  5. xadmin系列之零碎的小点

    1.获取某张表的某个字段的属性 意思就是获取括号中的属性 class app1Person(models.Model): pid = models.AutoField(primary_key=True ...

  6. 解决jenkins的内存溢出问题

    在jenkins的控制台会看到如下信息: FATAL: Remote call on ime_checkcode failed java.io.IOException: Remote call on ...

  7. rbac 权限分配, 基于formset实现,批量增加

    这里需要两个知识点: - formset - 自动发现项目中的URL1. 什么是formset: Django中 form组件 或 ModelForm组件,用于做一个表单的验证. 接收前端form表单 ...

  8. sqlServer数据库备份与还原——差异备份与还原

    1.差异备份 是完整备份的补充 备份自上次完整备份以来的数据变动的部分 2.备份过程: 在做差异备份之前需要先进行完整备份.完整备份的过程见:https://i.cnblogs.com/EditPos ...

  9. python 虚拟环境操作 virtualenv +virtualenvwrapper

    Window 下创建python的虚拟环境 下载工具 pip install virtualenv 创建虚拟环境目录 # 注意此命令创建的虚拟环境目录是在当前目录下 virtualenv testen ...

  10. IntelliJ idea 的破解

    ·1.破解的jar包下载链接: https://pan.baidu.com/s/1JV6GwguGQNs5pNQtst29Hw  提取码: u2jd 2.安装和破解地址:https://www.cnb ...