Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public boolean containsSuffix(String str) {
  2. Node node = root;
  3. while (true) {
  4. if (str.isEmpty()) {
  5. return node.children.isEmpty(); // return node.isleaf
  6. }
  7. node = node.children.get(String.valueOf(str.charAt(0)));
  8. if (node == null) {
  9. return false;
  10. }
  11. String label = node.getlabel(s);
  12. if (str.startsWith(label)) {
  13. str = str.substring(label.length());
  14. } else {
  15. return false;
  16. }
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement