Turning a recursive function into a for loop?
问题 Does every recursive function have an equivalent for loop? (Both achieve the same result). I have this recursive function: private static boolean recur(String word, int length) { if(length == 1 || length == 2) return false; if(length == 0) return true; if(words[length].contains(word.substring(0, length))) return recur(word.substring(length), word.length() - length); return recur(word, length-1); } Given that words is a Set[], and where words[i] = a set with words of length i. What am trying