leetcode 415 两个字符串相加
string addstring(string s1,string s2)
{
string ans="";
int f=;
for(int i=s1.length()-,j=s2.length()-;i>=||j>=;i--,j--)
{
int x=i<?:s1[i]-'';
int y=j<?:s2[j]-'';
char c=(x+y+f)%+'';
ans=c+ans;
f=(x+y+f)/;
}
if(f==)
ans=''+ans;
return ans;
}
leetcode 415 两个字符串相加的更多相关文章
- [LeetCode] 415. Add Strings 字符串相加
Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. ...
- [leetcode]415. Add Strings字符串相加
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2 ...
- 415 Add Strings 字符串相加
给定两个字符串形式的非负整数 num1 和num2 ,计算它们的和.注意: num1 和num2 的长度都小于 5100. num1 和num2 都只包含数字 0-9. num1 和 ...
- Leetcode 583.两个字符串的删除操作
两个字符串的删除操作 给定两个单词 word1 和 word2,找到使得 word1 和 word2 相同所需的最小步数,每步可以删除任意一个字符串中的一个字符. 示例 1: 输入: "se ...
- Java实现 LeetCode 712 两个字符串的最小ASCII删除和(最长公共子串&&ASCII值最小)
712. 两个字符串的最小ASCII删除和 给定两个字符串s1, s2,找到使两个字符串相等所需删除字符的ASCII值的最小和. 示例 1: 输入: s1 = "sea", s2 ...
- Java实现 LeetCode 583 两个字符串的删除操作(求最长公共子序列问题)
583. 两个字符串的删除操作 给定两个单词 word1 和 word2,找到使得 word1 和 word2 相同所需的最小步数,每步可以删除任意一个字符串中的一个字符. 示例: 输入: " ...
- LeetCode:1_Two_Sum | 两个元素相加等于目标元素 | Medium
题目: Given an array of integers, find two numbers such that they add up to a specific target number. ...
- Leetcode 712. 两个字符串的最小ASCII删除和
题目描述: https://leetcode-cn.com/problems/minimum-ascii-delete-sum-for-two-strings/ 解题思路: 也是典型的dp问题.利用二 ...
- LeetCode:字符串相加【415】
LeetCode:字符串相加[415] 题目描述 给定两个字符串形式的非负整数 num1 和num2 ,计算它们的和. 注意: num1 和num2 的长度都小于 5100.num1 和num2 都只 ...
随机推荐
- loadrunner中JavaVuser脚本的编写
1.环境准备: LoadRunner11----->对应JDK1.6版本(32位) LoadRunner12----->对应JDK1.7版本(32位) (一).JDK下载安装完成 ...
- js及jsp区别
- cowboy源码分析(二)
接 cowboy源码分析(一) 下面我们重点看看cowboy_protocol.erl代码 -module(cowboy_protocol). %% API. -export([start_link/ ...
- C# 一些不注意知识点:命名空间,等级,class等等
C# 命名空间表示域,控制着域内的对象. 命名空间是第一等级,class,delegate,enum,interface,struct是第二等级: 方法,属性,字段,索引,事件,常量,构造函数,终结器 ...
- SWUST OJ(1035)
定位顺序表中最大和最小值 #include<iostream> #include<cstdlib> using namespace std; int main(int argc ...
- git reset 和 git revert 使用区别
git reset 用于回退代码,但是git pull后会和远程分支保持一致,所以无法修改远程代码 git revert可以撤销代码,撤销后直接git push ,可以修改远程分支的代码
- feign调用超时
Feign调用超时 feign调用超时 默认feign调用超时是1秒,断点调试是否调用成功肯定超时 feign.hystrix.enabled=true #feign调用默认是1000毫秒=1秒 ad ...
- windows异步通知I/O模型
回声服务器端: #include <stdio.h> #include <stdlib.h> #include <WinSock2.h> #define BUF_S ...
- fiddler 4 设置代理
Windows使用一种被称为“AppContainer”的隔离技术,它可能会干扰lmmersive应用程序和Edge浏览器的流量捕捉.使用进度Telerik Fiddler的工具栏上的WinConfi ...
- golang开源项目qor快速搭建网站qor-example运行实践
最近想找几个基于Go语言开发的简单的开源项目学习下,分享给大家,github上有心人的收集的awesome-go项目集锦:github地址 发现一个Qor项目: Qor 是基于 Golang 开发的的 ...