All pastes #344144 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-02-07 15:47 UTC
rendered paste body
public class stuff
{
  public static boolean isPower2(int n)
  {
    return n >= 1 && (n == 2 || isPower2(n / 2));
  }
  public ListNode reverse(ListNode head)
  {
    if(head == null)
      return null;
    return new ListNode(head.getValue(), reverse(head.getNext()));
  }
  private boolean isWord(String s)
  {
    return s.length() > 0 & s.charAt(0).isLetter() && (s.length() == 1 || isWord(s.substring(0)));
  }
  public boolean isPhrase(String s)
  {
    String[] words = s.split();
    return isWord(words[0]) && 
           (words[0].length() == s.length() || isPhrase(s.substring(words[0].length()+1)));
  }
}