weikee94 / leetcode

A leetcode a day keeps unemployment away 😎
1 stars 0 forks source link

03 递归、分治和回溯 😎 #2

Open weikee94 opened 4 years ago

weikee94 commented 4 years ago

Recursion Screenshot 2020-08-16 at 11 16 25 AM

三要点


def recursion(level, param1, param2, ...)
  # recursion terminator 
  if(level > MAX_LEVEL)
    process_result
    return

  # process logic in current level 
  process(level, data...)

  # drill down 
  self.recursion(level+1, p1, ...)

  # reverse the current level status if needed