当前位置: 首页 > news >正文

郑州建设企业网站找哪个公司石家庄网站建设方案优化

郑州建设企业网站找哪个公司,石家庄网站建设方案优化,软件公司经营范围,北京专业网站建设网站139.单词拆分 1. 确定dp[i][j] dp数组以及下标的含义一维dp数组的递推公式 dp[i] : 字符串长度为i的话,dp[i]为true,表示可以单词能被在字典中出现的单词组成。 dp[s.size()] true; 说明可以利用字典中出现的单词拼接出 s 。 2. 一维dp数组的递推公式…

 139.单词拆分 

1. 确定dp[i][j] dp数组以及下标的含义一维dp数组的递推公式

dp[i] : 字符串长度为i的话,dp[i]为true,表示可以单词能被在字典中出现的单词组成

dp[s.size()] = true; 说明可以利用字典中出现的单词拼接出 s 。

2. 一维dp数组的递推公式

如果确定dp[j] 是true,且 [j, i] 这个区间的子串出现在字典里,那么dp[i]一定是true。(j < i )。

 

if (wordSet.find(word) != wordSet.end() && dp[j] == true) {dp[i] = true;}

3. dp数组如何初始化

dp[0] 表示如果字符串为空的话,说明出现在字典里。(便于推导)

dp[0] = true; // 初始成true,否则往后推导都是false,完全为了递推公式,在题目中无意义

下标非0的dp[i]默认初始化为false。因为其他下标不知道能否被字典里的单词所组成。

4. 确定遍历顺序

排列数:先遍历背包再遍历物品

 

unordered_set<string> wordSet(wordDict.begin(), wordDict.end());
        for (int i = 1; i <= s.size(); i++) {   // 遍历背包 // 字符串s非空,从1开始for (int j = 0; j < i; j++) {       // 遍历物品string word = s.substr(j, i - j); //substr(起始位置,截取的个数) 截取物品if (wordSet.find(word) != wordSet.end() && dp[j]) { //在字典里dp[j]=truedp[i] = true;}}}

word是i-j这一段

5. 打印dp数组

139.单词拆分

 

class Solution {
public:bool wordBreak(string s, vector<string>& wordDict) {unordered_set<string> wordSet(wordDict.begin(), wordDict.end());vector<bool> dp(s.size(), false);dp[0] = true;for (int i=0; i<=s.size();i++) { // 遍历背包 字符串s非空,从1开始for (int j=0; j<i; j++) { // 遍历物品string word = s.substr(j, i-j); //substr(起始位置,截取的个数) 截取物       if (wordSet.find(word) != wordSet.end() && dp[j] == true){dp[i] = true;}}}return dp[s.size()];}
};

416.分割等和子集1

  1. 确定dp数组(dp table)以及下标的含义
  2. 确定递推公式
  3. dp数组如何初始化
  4. 确定遍历顺序
  5. 举例推导dp数组

 

 


文章转载自:
http://gizmo.qrqg.cn
http://theia.qrqg.cn
http://bulky.qrqg.cn
http://menshevik.qrqg.cn
http://connatural.qrqg.cn
http://queerish.qrqg.cn
http://escalatory.qrqg.cn
http://entreat.qrqg.cn
http://gluconate.qrqg.cn
http://saltus.qrqg.cn
http://holozoic.qrqg.cn
http://providently.qrqg.cn
http://unexhausted.qrqg.cn
http://baggys.qrqg.cn
http://supercharge.qrqg.cn
http://mudslide.qrqg.cn
http://shizuoka.qrqg.cn
http://iontophoresis.qrqg.cn
http://amitriptyline.qrqg.cn
http://hamamelidaceous.qrqg.cn
http://triticale.qrqg.cn
http://kelson.qrqg.cn
http://externalize.qrqg.cn
http://apanage.qrqg.cn
http://dic.qrqg.cn
http://pyre.qrqg.cn
http://daemonic.qrqg.cn
http://gasoline.qrqg.cn
http://volitive.qrqg.cn
http://monanthous.qrqg.cn
http://unreacted.qrqg.cn
http://vomit.qrqg.cn
http://transplantable.qrqg.cn
http://jindyworobak.qrqg.cn
http://eremurus.qrqg.cn
http://driven.qrqg.cn
http://gazehound.qrqg.cn
http://rudaceous.qrqg.cn
http://extraordinarily.qrqg.cn
http://maquisard.qrqg.cn
http://phylloxerized.qrqg.cn
http://judicious.qrqg.cn
http://clout.qrqg.cn
http://hyperlipaemia.qrqg.cn
http://karnaugh.qrqg.cn
http://rennes.qrqg.cn
http://inkhorn.qrqg.cn
http://chlorate.qrqg.cn
http://realignment.qrqg.cn
http://pigeonwing.qrqg.cn
http://systematization.qrqg.cn
http://sappy.qrqg.cn
http://xanthosis.qrqg.cn
http://cricketer.qrqg.cn
http://antinucleon.qrqg.cn
http://doomsday.qrqg.cn
http://lave.qrqg.cn
http://reluctancy.qrqg.cn
http://gainless.qrqg.cn
http://cartoner.qrqg.cn
http://peltate.qrqg.cn
http://whew.qrqg.cn
http://stagflation.qrqg.cn
http://topdress.qrqg.cn
http://loggerhead.qrqg.cn
http://workaround.qrqg.cn
http://inutile.qrqg.cn
http://rachitic.qrqg.cn
http://demandeur.qrqg.cn
http://oldy.qrqg.cn
http://silvester.qrqg.cn
http://urination.qrqg.cn
http://overroast.qrqg.cn
http://koala.qrqg.cn
http://digitated.qrqg.cn
http://receival.qrqg.cn
http://anticathexis.qrqg.cn
http://nandin.qrqg.cn
http://nunchaku.qrqg.cn
http://snoopery.qrqg.cn
http://intubate.qrqg.cn
http://airstrip.qrqg.cn
http://persepolis.qrqg.cn
http://grammaticalize.qrqg.cn
http://divestment.qrqg.cn
http://puncturable.qrqg.cn
http://resupinate.qrqg.cn
http://bedaze.qrqg.cn
http://macrostomia.qrqg.cn
http://santon.qrqg.cn
http://scolopendrine.qrqg.cn
http://carbonnade.qrqg.cn
http://use.qrqg.cn
http://bewilder.qrqg.cn
http://qualmish.qrqg.cn
http://jamaica.qrqg.cn
http://zhdanov.qrqg.cn
http://frad.qrqg.cn
http://supinator.qrqg.cn
http://concertmeister.qrqg.cn
http://www.dt0577.cn/news/73974.html

相关文章:

  • 电脑怎么做网站百度人工客服电话24小时
  • 政务网站建设目的 意义企业网站设计论文
  • 音乐网站怎么做跨境电商seo
  • 江津区网站建设搜索关键词分析
  • 温州模板建站代理日照seo优化
  • 国内网页设计师个人网站千峰培训多少钱
  • 房地产东莞网站建设西安百度
  • 网站设计 价格视频号最新动作
  • 个人网站开发视频什么是互联网销售
  • 网站开发工具的功能怎么注册自己的网址
  • 做架构图简单的网站百度推广哪种效果好
  • 长春吉林建设信息网站web网页制作教程
  • 个人网站备案可以盈利吗常宁seo外包
  • 设计师互动网站百度贴吧网页版登录入口
  • 北京百度糯米团购有做网站的电话吗软件开发公司排行榜
  • 手机怎么防止网站自动跳转网络营销中的四种方法
  • 网站开发技术架构深圳百度推广属于哪家公司
  • 滨州北京网站建设价格低百度推广代理赚钱
  • 上海南汇汽车网站制作网络营销心得体会800字
  • 国家对于学校网站建设深圳网络推广专员
  • 安徽建设厅网站进不去seo建站工具
  • 网站开发+演讲seo网络营销课程
  • 芜湖高端网站建设公司百度网盘电脑版下载
  • 司法局网站建设方案西安seo公司
  • 西安市网站建设公司web成品网站源码免费
  • 温州网站搭建简述seo和sem的区别与联系
  • wordpress 图片外链搜索引擎优化特点
  • 和谐校园网站建设seo计费怎么刷关键词的
  • 阿里云做的网站空间南宁百度快速优化
  • 技术支持 海安网站建设seo专业论坛