Advertisement
UriSteiff

Untitled

Apr 15th, 2021
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. // create substrings table
  2. // String[][] substrings = new String[words.length][words.length];
  3. //
  4. // // first diagonal
  5. // for (int i = 0; i < substrings.length; i++) {
  6. // substrings[i][i] = words[i];
  7. // }
  8. //
  9. // // second diagonal
  10. // for (int i = 0; i < substrings.length - 1; i++) {
  11. // if (substrings[i][i].compareTo(substrings[i+1][i+1]) <= 0) {
  12. // substrings[i][i+1] = substrings[i][i] + " " + substrings[i+1][i+1];
  13. //
  14. // }
  15. // else {
  16. // substrings[i][i+1] = substrings[i][i];
  17. // }
  18. // }
  19.  
  20.  
  21. // for (int j = 1; j < substrings.length - 1; j++) {
  22. // for (int i = 0; i < substrings.length - 1; i++) {
  23. // if ((i+j) < substrings.length - 1) {
  24. // if (substrings[i][i+j].compareTo(substrings[i+j][i+j+1]) <= 0) {
  25. // substrings[i][i+j+1] = substrings[i][i+j-1] + " " + substrings[i+j][i+j+1];
  26. //
  27. // }
  28. // else if (substrings[i][i+j].compareTo(words[i+j+1]) <= 0) {
  29. // substrings[i][i+j+1] = substrings[i][i+j] + " " + words[i+j+1];
  30. // }
  31. // else {
  32. // substrings[i][i+j+1] = substrings[i][i+j];
  33. // }
  34. // }
  35. // }
  36.  
  37.  
  38. // String maxSubString = "";
  39. // for (int i = 0; i < substrings.length; i++) {
  40. // int curLen = substrings[i][substrings.length - 1].split(" ").length;
  41. // if (curLen >= maxSubString.split(" ").length) {
  42. // maxSubString = substrings[i][substrings.length - 1];
  43. // }
  44. // }
  45. //
  46. // return maxSubString;
  47. //
  48. // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement