Learn Profiling 2 -- Java Origin This time we profiling a java program. When I implement a problem to solve the longest-palindromic-substring problem which described in leetcode . I thought the running time should be O(n^2) and should pass the test. But result is time limit exceed. So I decide to profile my program to find out the problem. Tool We use a tool called JProfiler(which is very powerful but need to pay for it). Source Full source is at gist . Part of code about code tuning is following(before tuning): int len = string . length ( ) ; final LinkedList < PalindromicCenter > centers = new LinkedList < > ( len * 2 - 1 ) ; final char [ ] toCharArray = string . toCharArray ( ) ; { int j = 0 ; for ( int in = 0 ; in < toCharArray . length - 1 ; in ++ ) { centers . add ( new PalindromicCenter ( 1 , j ++ ) ) ; centers . add ( new PalindromicCenter ( 0 , j ++ ) ) ; ...
Learn programming, still on the way