844. Backspace String Compare
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的更多相关文章
- 【Leetcode_easy】844. Backspace String Compare
problem 844. Backspace String Compare solution1: class Solution { public: bool backspaceCompare(stri ...
- 844. Backspace String Compare判断删除后的结果是否相等
[抄题]: Given two strings S and T, return if they are equal when both are typed into empty text editor ...
- [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 ...
- [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 ...
- 【LeetCode】844. Backspace String Compare 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字符串切片 栈 日期 题目地址:https://le ...
- [LeetCode] Backspace String Compare 退格字符串比较
Given two strings S and T, return if they are equal when both are typed into empty text editors. # m ...
- [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 ...
- LeetCode - Backspace String Compare
Given two strings S and T, return if they are equal when both are typed into empty text editors. # m ...
- 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 ...
随机推荐
- verilog task1
问题描述: 设计中需要重复多次施加一种激励,每一次激励的施加过程,都可以划分为4个部分,如图所示. 每一次施加的激励只有第二部分的数据有变化(数据格式无变化).所以顶层的Testbench代码如下: ...
- 有关vim的一些命令
所有的 Unix Like 系统都会内建 vi 文书编辑器,其他的文书编辑器则不一定会存在. 但是目前我们使用比较多的是 vim 编辑器. vim 具有程序编辑的能力,可以主动的以字体颜色辨别语法的正 ...
- 贪吃蛇Global Java实现(二)
package cn.tcc.snake.util; public class Global {public static final int CELL_SIZE=20;public static f ...
- Max Points on a Line (HASH TABLE
QUESTIONGiven n points on a 2D plane, find the maximum number of points that lie on the same straigh ...
- Jmeter录制APP脚本
启动 jmeter.bat 在 Test Plan 下 添加 Thread Group 在 WorkBench 下 添加 HTTP(S) Test Script Recorder: 配置 Global ...
- 关于客户端调用后台事件__doPostBack函数的使用
1. 动态添加生成的控件:Asp.net开发网站,最喜欢用的就是使用服务器控件,在后台进行数据操作了,你无需再去管get还是post提交,也不用去理会form,只需在后台服务器控件的事件中就可以对 ...
- 2017.9.26JQuery源码解析一 架构与依赖
jq1.0: css选择符 事件处理 ajax交互 1.2.3: 引入数据缓存,解决循环引用与大数据保存问题 1.3. : 使用全新的选择器引擎sizzle,在各个浏览器下全面超越其他同类js ...
- Sqlite文件在ubunut的查看
1. How to list the tables in a SQLite database file that was opened with ATTACH? The .tables, and .s ...
- 计数器counter
今天就讲了2个属性:1.计数器 2.列规则 列规则很简单:column-count:3; (列的具体个数) column-width:30px;(列宽)N个浏览器不兼容column-gap:10px; ...
- 在linux上创建slave节点
在slave机器上创建一登录用户,步骤如下: 切换至/usr/sbin目录,执行useradd -m test007 -d /home/test007,test007就是我们所创建的用户 执行su+ ...