JAVA|| BITMASKING + DP || RECURSIVELY
SUPPOSE YOU HAVE [9,6,9] AND SEESIONTIME=14\nSO U CAN MAKE A BITMASK 000\nWHEN YOU TAKE 9 BIT MASK BECOMES 1000 AS 9 IS LESS THAN 14 YOU SEND recursive(9,1000)\
SUPPOSE YOU HAVE [9,6,9] AND SEESIONTIME=14\nSO U CAN MAKE A BITMASK 000\nWHEN YOU TAKE 9 BIT MASK BECOMES 1000 AS 9 IS LESS THAN 14 YOU SEND recursive(9,1000)\nthen you got 6 adding 6+9 you get 15 so u send 1+recursive(6,110)\nnow you have 9+6 you get 15 so u have greater than 14 so you send recursive(9,111)\nas you base condition 111 which is 7 so you see the sum which is not 0 which is greater than 0 so you send 1 if it was equal to 0 you must have send 0\n\nsee my code below\n\n\n```\n public static int val(int arr[],int sessionTime,int sum,int n,int mask,int dp[][])\n    {\n        if(mask==(1<<n)-1)//base condition\n        {\n            if(sum==0)\n            {\n                return 0;\n            }\n            else\n            if(sum>0)\n            {\n                return 1;\n            }\n        }\n        if(dp[mask][sum]!=-1)// taken dp of mask and sum\n        {\n            return dp[mask][sum];\n        }\n        int min=Integer.MAX_VALUE;\n        for(int i=0;i<n;i++)\n        {\n            if((mask&(1<<i))==0)\n            {\n                if(sum+arr[i]==sessionTime)//if sum+9==14\n                {\n                    int val1=val(arr,sessionTime,0,n,(mask|(1<<i)),dp);\n                    if(val1!=Integer.MAX_VALUE)\n                    {\n                        val1=val1+1;\n                    }\n                    min=Math.min(val1,min);\n                }\n                else\n                if(sum+arr[i]<sessionTime)//if sum+9<14\n                { \n                    int val1=val(arr,sessionTime,sum+arr[i],n,(mask|(1<<i)),dp);\n                      min=Math.min(val1,min);\n                }\n                else\n                if(sum+arr[i]>sessionTime)//if sum+9>14\n                {\n                    int val1=val(arr,sessionTime,arr[i],n,(mask|(1<<i)),dp);\n                    if(val1!=Integer.MAX_VALUE)\n                    {\n                        val1=val1+1;\n                    }\n                    min=Math.min(val1,min);\n                }\n            }\n        }\n        return dp[mask][sum]=min;\n    }\n```\n```\n public int minSessions(int[] tasks, int sessionTime)\n    {\n        int n=tasks.length;\n        int dp[][]=new int[1<<(n+1)-1][20];\n        for(int i=0;i<(1<<n);i++)\n        {\n            for(int j=0;j<20;j++)\n            {\n                dp[i][j]=-1;\n            }\n        }\n```\n\n**IF U LIKE THE SOLUTION ITS YOUR WISH TO UPVOTE BUT PLS DONT DOWNVOTE**
['Dynamic Programming', 'Backtracking', 'Bitmask', 'Java']