Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // create substrings table
- // String[][] substrings = new String[words.length][words.length];
- //
- // // first diagonal
- // for (int i = 0; i < substrings.length; i++) {
- // substrings[i][i] = words[i];
- // }
- //
- // // second diagonal
- // for (int i = 0; i < substrings.length - 1; i++) {
- // if (substrings[i][i].compareTo(substrings[i+1][i+1]) <= 0) {
- // substrings[i][i+1] = substrings[i][i] + " " + substrings[i+1][i+1];
- //
- // }
- // else {
- // substrings[i][i+1] = substrings[i][i];
- // }
- // }
- // for (int j = 1; j < substrings.length - 1; j++) {
- // for (int i = 0; i < substrings.length - 1; i++) {
- // if ((i+j) < substrings.length - 1) {
- // if (substrings[i][i+j].compareTo(substrings[i+j][i+j+1]) <= 0) {
- // substrings[i][i+j+1] = substrings[i][i+j-1] + " " + substrings[i+j][i+j+1];
- //
- // }
- // else if (substrings[i][i+j].compareTo(words[i+j+1]) <= 0) {
- // substrings[i][i+j+1] = substrings[i][i+j] + " " + words[i+j+1];
- // }
- // else {
- // substrings[i][i+j+1] = substrings[i][i+j];
- // }
- // }
- // }
- // String maxSubString = "";
- // for (int i = 0; i < substrings.length; i++) {
- // int curLen = substrings[i][substrings.length - 1].split(" ").length;
- // if (curLen >= maxSubString.split(" ").length) {
- // maxSubString = substrings[i][substrings.length - 1];
- // }
- // }
- //
- // return maxSubString;
- //
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement