Created by Wang, Jerry, last modified on Dec 18, 2015

in getAllPossibleSentences, s: catsanddog pos: 9
Sub string: catsanddog
逐一遍历字典里的word,检查当前子串是否以word结尾。
Sub String ends with word in Dict!: dog - 字典里找到一个匹配。
current position: 9 word length: 3
first Seg end: 6 找到匹配后准备开始递归。
RECURSIVELY call, new position: 6
in getAllPossibleSentences, s: catsanddog pos: 6 - 传s还是传整个字符串进去,只是position变成前6个。此时执行流不会返回,仍然是在当前dog匹配的大前提下。
Sub string: catsand
Sub String ends with word in Dict!: sand
current position: 6 word length: 4
first Seg end: 2
RECURSIVELY call, new position: 2 又找到一个匹配,再递归。
in getAllPossibleSentences, s: catsanddog pos: 2
Sub string: cat
Sub String ends with word in Dict!: cat - 再次找到匹配 dog->sand->cat
current position: 2 word length: 3
first Seg end: -1
RECURSIVELY call, new position: -1
in getAllPossibleSentences, s: catsanddog pos: -1
pos is -1, we can return now and have a rest! return result size: 1 - 这个是默认的space
result from getAllPossible with position: -1 - 从最内层的递归返回了一层。
result list’s item is STRING.space, so I directly insert end word to solution list: cat - 将最内层的cat结果加到list里。
Possible solution FOUND:!cat
insert map with position: 2 possible list: 1
[-1, “”]
[2, cat]
result from getAllPossible with position: 2
item in result list: cat - 从前一个递归insert的。Current word in dic: sand - 当前递归frame的单词。
Possible solution FOUND:!cat sand
Sub String ends with word in Dict!: and (Sub string: catsand)
current position: 6 word length: 3
first Seg end: 3
RECURSIVELY call, new position: 3
in getAllPossibleSentences, s: catsanddog pos: 3
Sub string: cats
Sub String ends with word in Dict!: cats
current position: 3 word length: 4
first Seg end: -1
RECURSIVELY call, new position: -1
in getAllPossibleSentences, s: catsanddog pos: -1
pos is -1, we can return now and have a rest! return result size: 1
result from getAllPossible with position: -1
item in result list: Current word in dic: cats
result list’s item is STRING.space, so I directly insert end word to solution list: cats
Possible solution FOUND:!cats
insert map with position: 3 possible list: 1
result from getAllPossible with position: 3
item in result list: catsCurrent word in dic: and
Possible solution FOUND:!cats and
insert map with position: 6 possible list: 2
result from getAllPossible with position: 6
item in result list: cat sandCurrent word in dic: dog
Possible solution FOUND:!cat sand dog
item in result list: cats andCurrent word in dic: dog
Possible solution FOUND:!cats and dog
insert map with position: 9 possible list: 2
result: cat sand dog
result: cats and dog



























Java Word break analysis相关推荐

  1. leetcode word break java,Word Break leetcode java

    题目: Given a string s and a dictionary of words dict, determine if s can be segmented into a space-se ...

  2. Leetcode word break I II 词句拆分I和II的java实现及解析

    Leetcode word break I & II 词句拆分I和II的java实现及解析 word break i是leetcode 里面中等难度的题目而word break II 更是ha ...

  3. Java中return结束循环,Java中break、continue、return在for循环中的使用

    Java中break.continue.return在for循环中的使用 发布时间:2020-09-25 02:01:45 来源:脚本之家 阅读:81 作者:mrr 引言:在使用循环的时候,循环里面带 ...

  4. C++word break断字(基于单词或字符串)(附完整源码)

    C++word break断字的实现 C++word break断字的完整源码(定义,实现,main函数测试) C++word break断字的完整源码(定义,实现,main函数测试) #includ ...

  5. java中break内外循环_java 中break如何跳出外部循环

    学习就是为了不断的看到自己的知识盲点,然后改正,以前知道如何使用break来跳出循环,突然学习到可以用break跳出外部的循环(以前只知道怎么调本次的循环). 上正题代码如下: break跳出本次循环 ...

  6. leetcode 140. Word Break II | 140. 单词拆分 II(动态规划)

    题目 https://leetcode.com/problems/word-break-ii/ 题解 由 leetcode 139. Word Break | 139. 单词拆分(动态规划) 改造而来 ...

  7. java word批注_使用反射处理Java批注

    java word批注 在上一篇有关Java注释的文章中,我概述了一个最近的用例,并为您提供了一些自定义注释的示例以及如何使用它们. 在本文中,我将更进一步,并为您提供一些自定义注释的示例,以及如何使 ...

  8. java word批注_编写Java批注

    java word批注 Java 批注的允许的属性类型刻意非常严格,但是允许的类型也可以使用一些简洁的复合批注类型. 考虑教程站点中的示例注释: package annotation; @interf ...

  9. java word转html 乱码 poi,java word转html poi

    java word转html poi [2021-01-29 15:50:39]  简介: php去除nbsp的方法:首先创建一个PHP代码示例文件:然后通过"preg_replace(&q ...

最新文章

  1. 3.7Python数据处理篇之Numpy系列(七)---Numpy的统计函数
  2. Android之使用AchartEngineActivity引擎绘制柱状图、曲线图
  3. 行为型模式:状态模式
  4. JS-Demo1:JavaScript实现表格列拖动
  5. 从程序员到项目经理(九):程序员加油站 -- 再牛也要合群
  6. 这种简历咋找工作?(运营)
  7. linkin大话面向对象--内部类
  8. Domino中运用ajax判断帐号是否存在的简单例子
  9. NOI / 2.5基本算法之搜索7834:分成互质组(详细讲解)
  10. 编程语言中的句柄是什么?
  11. Unity笔记—常用小功能整合
  12. MySql获取某天是一年的第几周
  13. 电子产品--耐久性试验--可靠性试验--热测试试验--老化试验
  14. 大童保险确认获得投资:德弘资本等出资15亿元,获得约33%股权
  15. python之父:《Python程序员指南》这本书你应该了解以下,pdf
  16. 报Python培训班多少钱?报个班值得吗?
  17. 错误状态0xc00002e1解决方法
  18. hack the box 注册邀请码的获取
  19. [转] 绝对实用!60款免费软件逐个点评下载
  20. 数学知识——矩阵乘法

热门文章

  1. popwindow setFocusable(false) 不消失与弹出软键盘的冰火不容的矛盾
  2. PyTorch基础(part3)
  3. 第三次学JAVA再学不好就吃翔(part48)--String类的判断功能
  4. numpy基础(part7)--多项式拟合
  5. 这6种性格的人不适合做数据分析
  6. 使用 RxJs Observable 来避免 Angular 应用中的 Promise 使用
  7. SAP 电商云 Spartacus UI 支持延迟加载的新功能的入口设计
  8. SAP 电商云 Spartacus UI Proxy Facade 的一个实际例子
  9. Angular Component的加载触发时机
  10. SAP CDS view权限控制实现原理介绍