Skip to main content

Useful math

  • Total number of subset for a given array is 2^n
  • Combinations:

Permutations ^43a0c7

  • Total of permutations for a given array: n!/(n-k)! where k is the number of element we are trying to arrange ^082db8 => Permutation of the whole array n!
  • When we want the next greater number using the same digits as 12543, we want to make the smallest possible increase by changing as few digits as possible, starting from the right. The same principle applies to permutations. ^2b285a
    • Notice that 543 is already the largest possible arrangement
    • Pick 2 and then pick 3 as we are trying to make the smallest increase
    • We swap 2 and 3 to get 13542 but this is not the smallest increase
    • We have to sort everything after the swap (after 3 ) to make sure the right portion is smallest possible => 13245
    • This is actually happen if we do it by ourselves