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 ...
随机推荐
- Unity 场景分页插件 World Streamer 支持无限大地图的解决方案(二)
Terrain Streaming 可以用WorldCreator创建Tile地形,然后用WorldStreamer实现分块地图.比如10000*10000(16平方公里) 的地形,需要1000*10 ...
- Node使用 Express框架,实现文件上传
一 安装依赖包 npm install multer --save 二 客户端上传文件 <!DOCTYPE html> <html> <head> <meta ...
- stm32中adc的常规通道和注入通道的区别
STM32的每个ADC模块通过内部的模拟多路开关,可以切换到不同的输入通道并进行转换.STM32特别地加入了多种成组转换的模式,可以由程序设置好之后,对多个模拟通道自动地进行逐个地采样转换. 有2种划 ...
- DES对称加密
DES是对称性加密里面常见一种,全称为Data Encryption Standard,即数据加密标准,是一种使用密钥加密的块算法.密钥长度是64位(bit),超过位数密钥被忽略.所谓对称性加密,加密 ...
- Delphi: TGraphicControl支持PaintTo方法
Delphi之TWinControl支持PaintTo方法,可以方便的Paint有句柄控件,而此方法,TGraphicControl没有. 这使得有时需要Paint无句柄控件诸如TLabel时颇为费事 ...
- python 网络基础 之 网络协议
osi 七层协议 互联网协议按照功能不同分为osi七层或者tcp/ip 五层或tcp/ip 四层 tcp/ip 四层 1.应用层 2.传输层 3.网络层 4.网络接口层 tcp/ip 五层 1.应用层 ...
- c#tcp源端口号和目的端口怎么理解
在一台机器上,一个进程对应一个端口.端口的作用就是用来唯一标识这个进程.源端口标识发起通信的那个进程,目的端口标识接受通信的那个进程.有了端口号,接受到报文后才能够知道将报文发送到哪个进程.
- otool
一.简介 二.实例 1)查看动态链接库 otool -L /usr/bin/vim
- C# System.Data.OracleClient requires Oracle client software version 8.1.7 or greater
好好的程序,突然出现了错误,原因是:System.Data.OracleClient requires Oracle client software version 8.1.7 or greater, ...
- (轉)EasyUI - DataGrid 去右边空白滚动条列
熟悉 EasyUI - DataGrid 的童鞋应该会注意到这样一个情景: 想去掉这块,找了下资料,发现也有人同样纠结:http://www.cnblogs.com/hantianwei/p/3440 ...