16,020,822 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Visual Basic questions
View Javascript questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Animesh _1SG20IS008 (Top 12 by date)
Animesh _1SG20IS008
23-May-23 6:58am
View
Already did
Animesh _1SG20IS008
23-May-23 1:38am
View
Got the solution from youtube but can you please explain the significance of 'sz' variable.
string kPeriodic(string s, int k){
// code here
int n=s.size();
vector<int>m(26);
for (auto e:s) m[e-'a']++;
int sz=0;
int id=0;
string ans=string(n, '_');
while(ans[id]=='_'){
sz++;
ans[id]='.';
id+=k;
id%=n;
}
for(auto e:m) if(e%sz!=0) return "-1";
ans=string(n, '_');
id=0;
int cnt=0, val=0;
while(cnt!=n){
while(ans [id]!='_')id++; //find a blank pos
while(m[val]==0)val++;
while(ans[id]=='_'){
cnt++;
ans[id]='a'+val;
id+=k;
id%=n;
}
m[val]-=sz;
}
return ans;
}
Animesh _1SG20IS008
23-May-23 1:30am
View
Dynamic Programming
Animesh _1SG20IS008
23-May-23 1:30am
View
Dynamic Programming
Animesh _1SG20IS008
22-May-23 23:52pm
View
You can look on chatgpt for DP solution.As I'm not familiar with DP that's why came here looking for non DP solution.
Animesh _1SG20IS008
31-Aug-22 5:40am
View
When tried to submit this code on codeforces it is giving partial output as result.
Animesh _1SG20IS008
23-Jul-22 7:59am
View
Thanks it worked.
Animesh _1SG20IS008
23-Jul-22 1:51am
View
Don't know Sir I'm also confused around this one.
Animesh _1SG20IS008
23-Jul-22 0:16am
View
Thanks Rick for the help but still its giving the same error.
Animesh _1SG20IS008
23-Jul-22 0:09am
View
Line 1034: Char 9: runtime error: reference binding to null pointer of type 'std::vector<bool, std::allocator<bool="">>' (stl_vector.h)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1043:9
Animesh _1SG20IS008
23-Jul-22 0:09am
View
Line 1034: Char 9: runtime error: reference binding to null pointer of type 'std::vector<bool, std::allocator<bool="">>' (stl_vector.h)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1043:9
Animesh _1SG20IS008
26-Mar-22 14:15pm
View
Deleted
Yes my above code on execution is giving TLE in particular compiler can u explain why?
If u can provide some other solution to this problem with explaination it would be really helpful.
Show More