actually 4th question need tabulation only and your logic for 3rd is exact same for 4th question here's the code: #define ll long long class Solution { public: int row, col; long long maximumValueSum(vector& board) { vector temp(board.size(), vector(board[0].size())); row = board.size(); col = board[0].size(); for(int i=0; i
@@tejasjaulkar9658 However, the constant factor in terms of execution speed might differ between the two approaches, as tabulation avoids the overhead of recursive function calls. In practice, this makes tabulation sometimes slightly faster.( therefore always try optimizing your code upto tabulation if possible)
we can also do it using normal knapsack way, by storing all the ( row , col ) combination in a vector pair and choose the maximum 3 pairs which are valid, by using either a additional array or simple mapping
Bhai to be honest the dp you are using in 3rd question is of no use, in the dp you are storing result of a triplet of indexes. and any triplet won't occur twice in any case. So it won't ever enter the case (if dp[i][firstj+1][secondj+1] != -1) So that would get accepted without even using dp. The memoization you used was of no use. Anyways Great Explanation... Keep putting up such content.
Hello Abhinav Bhai. Firstly your videos are really helpful thanks for it. I want to ask how should I improve in contests. I have solved 300+ problems on Leetcode and today I gave my 8th contest. but i was only able to solve first problem and was not able to optimize it. Usually also I am able to solve only 2 ques. in lc contest ( 1 easy 1 medium). I dont know what i am doing wrong. HOW CAN I IMPROVE?
bhai 1 question toh maine hi kar liya tha aaj. it was my first contest and i have only solved 42 leetcode problems. I think tumhe logic bnane mein ya fir time constraint mein logic kaise bnana hai usme dikkat aa rahi hogi. Zyada contest do aur khudse logic bnane ka try kro. Best of luck.
Bro we are sailing in the same boat , I started solving problems in Leet code from last year end , Sometimes we solve medium questions easily in contest because we previously solved same pattern questions or same logic questions the only way to mastering logical thinking is to solve more problems without thinking about failure, Understanding the problem statement (most of us failed in this) after comes with brute force solution don't think about optimal solution first, because it's leading to wrong solution. Most importantly don't give up if you feel demotivated take break or try understanding others solutions we learn from our mistakes I solved q2 using queue Don't overthink, keep going on path
Please Like and Comment
Join Whatsapp Channel: whatsapp.com/channel/0029Va55Idf1NCrU16kHOt3j
Join Telegram Channel: telegram.me/cpabhinav
Very nice explanation of problem C
actually 4th question need tabulation only and your logic for 3rd is exact same for 4th question
here's the code:
#define ll long long
class Solution {
public:
int row, col;
long long maximumValueSum(vector& board) {
vector temp(board.size(), vector(board[0].size()));
row = board.size();
col = board[0].size();
for(int i=0; i
nice soln.
but tc is always same for memoi and tabulation only sc is changing so how
@@tejasjaulkar9658 However, the constant factor in terms of execution speed might differ between the two approaches, as tabulation avoids the overhead of recursive function calls. In practice, this makes tabulation sometimes slightly faster.( therefore always try optimizing your code upto tabulation if possible)
Thanks , Good content
we can also do it using normal knapsack way, by storing all the ( row , col ) combination in a vector pair and choose the maximum 3 pairs which are valid, by using either a additional array or simple mapping
bhaiya aapka hi intezaar tha pls baaki codechef and codeforces ke solution bhi nikaala karo..aapke approaches are very intuitive
Is it possible to solve first question in SC 0(1) ?
Bhai to be honest the dp you are using in 3rd question is of no use, in the dp you are storing result of a triplet of indexes. and any triplet won't occur twice in any case. So it won't ever enter the case (if dp[i][firstj+1][secondj+1] != -1) So that would get accepted without even using dp. The memoization you used was of no use. Anyways Great Explanation... Keep putting up such content.
Bro, you are wrong
It's not possible
If you think it is possible, can you please share the code
Yeah, that is what I am asking, can you please do the same and send me the submission link?
Helpful
Great explaination
Can't A problem solved with sliding window??
We can solve it using sliding window approach
please upload weekly contest solution also
Hello Abhinav Bhai. Firstly your videos are really helpful thanks for it. I want to ask how should I improve in contests. I have solved 300+ problems on Leetcode and today I gave my 8th contest. but i was only able to solve first problem and was not able to optimize it. Usually also I am able to solve only 2 ques. in lc contest ( 1 easy 1 medium). I dont know what i am doing wrong. HOW CAN I IMPROVE?
bhai 1 question toh maine hi kar liya tha aaj. it was my first contest and i have only solved 42 leetcode problems. I think tumhe logic bnane mein ya fir time constraint mein logic kaise bnana hai usme dikkat aa rahi hogi. Zyada contest do aur khudse logic bnane ka try kro. Best of luck.
Bro we are sailing in the same boat , I started solving problems in Leet code from last year end ,
Sometimes we solve medium questions easily in contest because we previously solved same pattern questions or same logic questions the only way to mastering logical thinking is to solve more problems without thinking about failure,
Understanding the problem statement (most of us failed in this) after comes with brute force solution don't think about optimal solution first, because it's leading to wrong solution.
Most importantly don't give up if you feel demotivated take break or try understanding others solutions we learn from our mistakes
I solved q2 using queue
Don't overthink, keep going on path
Really helpful
i thought this but didn't do😭😭
At contest i fidnt get b
Helpful
Helpful