What do we mean by removing k-1 values in problem A. We will keep those k-1 values in individual groups right?
@codingalley6229 Жыл бұрын
yes
@cpwithcpp Жыл бұрын
Consider that all adjacent elements have some links between them. Now each of those links will be contributing some value. If I remove one link the array will break into 2 parts. If I remove two links the array will break in to 3 parts and so on. So to have k parts in the final array I need to remove k - 1 links from them. And all the remaining links will be contributing some value to my answer. So it is optimal to remove the greatest k - 1 links.
@muhammadosamafahim7019 Жыл бұрын
@@cpwithcpp Sir, it is mentioned regarding contiguous subgroups , so sorting the array or only getting the first k minimums would destroy the contiguous subarray nature won't it ? apart from that the question is clear but I am unable to get this part only intuitively Thankyou
@muhammadosamafahim7019 Жыл бұрын
sir beautiful explanation of all the questions
@x_x3557 Жыл бұрын
after obtaining a1, if we choose a4 and a5 we get (a1, a4, a5) and we cannot obtain this in only 2 operations? Is this correct or am I missing out something?
@cpwithcpp Жыл бұрын
Please mention the question and the timestamp you are talking about.
@x_x3557 Жыл бұрын
@@cpwithcpp Problem C. 19:04. For the example below, If we perform the operations in the following sequence: i=4, i=2, i=3, the final xor obtained will be c, e, f which is not contiguous. How is this possible? [a, b, c, d, e, f] (e, f) (c, d, e, f), (e, f) (d, e, f), (c, d, e, f), (e, f) final xor = c, e, f
@zeroanims4113 Жыл бұрын
@@x_x3557 no i=3 should be = (d, e, f), (e, f), (c, d, e, f), (e, f) = c (u missed (e, f)) it should always be contiguous
@shankar1050 Жыл бұрын
but 2 xor 5 is 7 which contradicts your statement at 16:28
@cpwithcpp Жыл бұрын
Wrong choice of words. I meant to say the there will be no new bit introduced. That is why if we have 8 bits we are considering the maximum possible value with 8 bits and that is 256. I wanted to say that no new greater number can be formed in terms of new bits. I did not frame the sentence correctly there.
@shankar1050 Жыл бұрын
@@cpwithcpp got it
@shankar1050 Жыл бұрын
thankyou for responding
@CristianoRonaldo-ku1uz Жыл бұрын
Can you help me with my code. Where does it fails and what should I update in code? #include using namespace std; typedef long long ll; #define V vector #define pb push_back #define pi pair #define forl(var,str,end) for(long long int var=str; var>t; while(t--) { ll n; cin>>n; ll a[n]; forl(i,0,n){ cin>>a[i]; } ll ans = a[0]; forl(i,1,n){ ans = (ans&a[i]); } if(ans!=0) cout