Skip to main content

Posts

Showing posts from January, 2021

Codechef February long challenge solution 2021

   Codechef February  long challenge solution 2021- Hey guys Welcome Again, A small update CodeChef February  long challenge solution 2021 starting from 1st week of beb  2021 . Codechef long challenge is one of the popular contests of CodeChef you should participate in codechef Feb  long challenge.This is first contest of codechef in 2021 so good luck. And wish you happy new year. Contest link- https://www.codechef.com/FEB21/?itm_medium=navmenu&itm_campaign=FEB21 I will post the solution after Contest.Stay tuned. About CodeChef  February  long challenge solution 2021: CodeChef Long Challenge is a 10-day monthly coding contest where you can show off your computer programming skills. The significance being - it gives you enough time to think about a problem, try different ways of attacking the problem, read the concepts etc. If you’re usually slow at solving problems and have ample time at hand, this is ideal for you. We also put in a lot of efforts in getting quality problems, w

0-1 Knapsack Problem | DP-10 Solution Recursive memoization and Tabulation Full Explanation

 Problem Statement- You are given weights and values of  N  items, put these items in a knapsack of capacity  W  to get the maximum total value in the knapsack. Note that we have only  one quantity of each item . In other words, given two integer arrays  val[0..N-1]  and  wt[0..N-1]  which represent values and weights associated with  N  items respectively. Also given an integer W which represents knapsack capacity, find out the maximum value subset of  val[]  such that sum of the weights of this subset is smaller than or equal to  W.  You cannot break an item,  either pick the complete item, or don’t pick it (0-1 property) . Example 1: Input: N = 3 W = 4 values[] = {1,2,3} weight[] = {4,5,1} Output: 3 Example 2: Input: N = 3 W = 3 values[] = {1,2,3} weight[] = {4,5,6} Output: 0 Your Task: Complete the function  knapSack()  which takes maximum capacity W, weight array wt[], value array val[] and number of items n as a parameter and returns the  maximum possible  value you can get. Exp

Watching CPL Codechef January 2021 solution || Watching CPL codechef problem editorial 2021

 Watching CPL Codechef January 2021 solution || Watching CPL codechef problem editorial 2021- Problem statement- Get excited, folks, because it is time for the final match of Codechef Premier League (CPL)! Mike and Tracy also want to watch the grand finale, but unfortunately, they could not get tickets to the match. However, Mike is not someone who gives up so easily — he has a plan to watch the match. The field where the match is played is surrounded by a wall with height  K K . Outside, there are  N N  boxes (numbered  1 1  through  N N ). For each valid  i i , the  i i -th box has a height  H i H i . Mike wants to take some boxes and stack them on top of each other to build two towers. The height of each tower is the sum of heights of all the boxes that form it. Of course, no box may be in both towers. The height of each tower should be at least  K K . Then Mike can climb on top of one tower and Tracy on top of the other, and they can watch the match uninterrupted! Whil