A typical framework is
- Need a result list and levelList for each result
- The major loop will do scan over available elements(like Array, a group of arrays, set. etc.)
- The recursion needs to transfer level/pos information to next level
- original data has dup or no dup ? --> use standard (i>0 && n[i]==n[i-1]) to skip dup
- original data order is significant ? --> use full scan loop or incremental scan from pos+1
- final result should be be ordered like non-descending ? -- sort first
- result can have dup, no dup inside ? --> use levelList.contains() to uniquify
- track the current used pool ? visited[] flag vs hashset()
- result must include all elements ? --> subset/combination vs permutation
没有评论:
发表评论