Розмір відео: 1280 X 720853 X 480640 X 360
Показувати елементи керування програвачем
Автоматичне відтворення
Автоповтор
good morning sir,amazing just potd is live and you have uploaded the video,hatsoff to your dedication & consistency🙏First viewer
nice :)
Early morning.your efforts are really appreciated ❤🎉
Thank you so much 😀
Super explanation brother, keep going✨
thanks
Thank you sir :)
welcome 🤗
I counted the number of 1’s in the derived if their odd means false else zero 🙂
nice work :)
question dekha nhi solution phele aa gya lol
It also works by checking freq of 1 is even or not , idk y but it passed all cases😅
great
class Solution { public boolean doesValidArrayExist(int[] derived) { int n = derived.length; int ans =0; for(int i:derived){ ans ^=i; } if(ans==0){ return true; } return false; }}
👍🏼
why is this wrong? class Solution {public: bool doesValidArrayExist(vector& d) { if (d.size() == 0) { return true; } if (d.size() == 1) { return !d[0]; } int n = size(d); vector o1(n, 0), o2 = o1; if (d[n - 1] == 0) { o1[0] = 1, o2[0] = 0; o1[n - 1] = 1, o2[n - 1] = 0; } else { o1[0] = 0, o2[0] = 0; o1[n - 1] = 1, o2[n - 1] = 1; } for (int i = n - 2; i >= 1; i--) { if (d[i] == 1) { o1[i] = 0; o2[i] = 1; } else { o1[i] = 1; o2[i] = 0; } } return ((o1[0] ^ o1[1]) == d[0]) or ((o2[0] ^ o2[1]) == d[0]); }};
good morning sir,amazing just potd is live and you have uploaded the video,hatsoff to your dedication & consistency🙏First viewer
nice :)
Early morning.your efforts are really appreciated ❤🎉
Thank you so much 😀
Super explanation brother, keep going✨
thanks
Thank you sir :)
welcome 🤗
I counted the number of 1’s in the derived if their odd means false else zero 🙂
nice work :)
question dekha nhi solution phele aa gya lol
It also works by checking freq of 1 is even or not , idk y but it passed all cases😅
great
class Solution {
public boolean doesValidArrayExist(int[] derived) {
int n = derived.length;
int ans =0;
for(int i:derived){
ans ^=i;
}
if(ans==0){
return true;
}
return false;
}
}
👍🏼
why is this wrong?
class Solution {
public:
bool doesValidArrayExist(vector& d) {
if (d.size() == 0) {
return true;
}
if (d.size() == 1) {
return !d[0];
}
int n = size(d);
vector o1(n, 0), o2 = o1;
if (d[n - 1] == 0) {
o1[0] = 1, o2[0] = 0;
o1[n - 1] = 1, o2[n - 1] = 0;
} else {
o1[0] = 0, o2[0] = 0;
o1[n - 1] = 1, o2[n - 1] = 1;
}
for (int i = n - 2; i >= 1; i--) {
if (d[i] == 1) {
o1[i] = 0;
o2[i] = 1;
} else {
o1[i] = 1;
o2[i] = 0;
}
}
return ((o1[0] ^ o1[1]) == d[0]) or ((o2[0] ^ o2[1]) == d[0]);
}
};