LeetCode 1764. Form Array by Concatenating Subarrays of Another Array | BiWeekly Contest 228 | C++

preview_player
Показать описание
Just find one group then move to the next one .... and so on....

1 Like = Motivation x100 !!!
1 SUB= MOTIVATION x1000 !!!

Thanks for watching friends.
Please like and share with your friends it will give me motivation to make further videos.
Connect with me at
Рекомендации по теме
Комментарии
Автор

Will you be making video on Tree with Co primes?

ramanmanocha
Автор

class Solution {
public:
bool solve(vector<vector<int>>& groups, vector<int>& nums, int gi, int ni)
{
if(gi==groups.size() ) return true;

vector<int> gg=groups[gi];
int i=ni;



while(i<nums.size()){

for(int j=0;j<gg.size();j++){

if(gg[j]!=nums[i++])
{

if(j!=0)i--;
break;
}
if(j==gg.size()-1 && solve(groups, nums, gi+1, i)==true)
return true;
}
}
return false;
}


bool groups, vector<int>& nums) {

int gi=0, ni=0;

return solve(groups, nums, gi, ni);
}
};


this is the same code but it's not working for one test case. could you please find out the errror in this code . groups=[[21, 22, 21, 22, 21, 30]]
nums=[21, 22, 21, 22, 21, 22, 21, 30] expected output-true
actual
output false

akshatkothari
join shbcf.ru