Interview Question for Software Analysts
- -1of 1 vote
AnswersThis is the implementation for KMP shift table or the processing of pattern. Is the implementation correct ?Please provide test cases to break the code.
public static String longestPrefSuff(char arr[]) { int k[] = new int[arr.length]; int i = 0, j = 0; for (int m = 0; m < arr.length; m++) { if (m == 0) { j++; k[m] = 0; } else { if (arr[i] == arr[j]) { k[m] = k[m - 1] + 1; i++; j++; } else { i = 0; if (arr[i] == arr[j]) { i++; k[m] = 1; } j++; } } } return Arrays.toString(k);
}
- koustav.adorable April 19, 2015 in India| Report Duplicate | Flag | PURGE
Software Analyst Algorithm
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
Interview Type: Phone Interview
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.