Your Solution Ideas #10
Replies: 4 comments 4 replies
-
For potd , 10 Nov 2023 `string printMinNumberForPattern(string S){
}` |
Beta Was this translation helpful? Give feedback.
-
For potd 14 Nov,
|
Beta Was this translation helpful? Give feedback.
-
for POTD - 26 NOV ; it's mentioned to not use loops.
class Solution{
public:
bool decreasing = true;
void patternHelper(int current, int initial,vector<int>& result) {
/*
cout<<"function started : ";
for(int u: result){
cout<<u<<" ";
}
cout<<endl;
*/
if(current > initial){
return;
}else if(decreasing){
result.push_back(current);
if(current <= 0){
decreasing = false;
patternHelper(current+5,initial,result);
}else{
patternHelper(current-5,initial,result);
}
}else{
result.push_back(current);
patternHelper(current+5,initial,result);
}
}
vector<int> pattern(int N){
// code here
vector<int> result;
patternHelper(N,N,result);
return result;
}
}; |
Beta Was this translation helpful? Give feedback.
-
08-02-2024 class Solution{
}; |
Beta Was this translation helpful? Give feedback.
-
Please provide your solution Ideas here...
Very Welcome
<Happy Coding/>
Beta Was this translation helpful? Give feedback.
All reactions