How to keep the time low when submitting question on coding Platforms Like Leetcode? #178729
Unanswered
Omkumar2003
asked this question in
Programming Help
Replies: 1 comment
-
Overview
Optimized CodeKey ImprovementsReadability:
Efficiency:
Removed Unnecessary Code:
Performance Consideration (See more in
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Body
So I was working on the Longest Palindromic Substring problem, and I thought — let's keep the same
O(n^3)logic, but just change the way it’s implemented, not the core idea.I heard from someone that you should warm up the JVM with small dummy inputs so that it can optimize and run faster later.
Wherever possible, use pointers instead of creating new objects (like using substring).
Also, regarding String vs StringBuilder vs char[] — using a char array is usually the fastest.
Are there any other ways to make a program faster, like some
competitive programming tips?So I came up with the following solution, which is quite fast and still O(n^3)
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions