一、题目内容

image.png

二、题解

解法1:

思路

代码

  1. public class Solution {
  2. public int solve(int n, int k) {
  3. // write code here
  4. int t = 1;
  5. while(recur(t, k) < n + 1){
  6. t++;
  7. }
  8. return t;
  9. }
  10. private int recur(int t, int k) {
  11. if(t == 1 || k == 1){
  12. return t + 1;
  13. }
  14. return recur(t - 1,k - 1) + recur(t-1,k);
  15. }
  16. }