Skip to content

PhonePe Coding Questions - DSA Problems & Solutions

Practice PhonePe placement paper coding questions with detailed solutions. Access PhonePe OA coding problems in Java, Python, C++, Go.

This page contains PhonePe coding questions from PhonePe OA placement papers with detailed solutions.

PhonePe OA Coding Section:

  • Problems: 2-3 coding problems
  • Time: 90 minutes
  • Languages: Java, Python, C++, Go
Q1: Find the longest palindromic substring in a string.

Solution (Java):

public String longestPalindrome(String s) {
if (s == null || s.length() < 1) return "";
int start = 0, end = 0;
for (int i = 0; i < s.length(); i++) {
int len1 = expandAroundCenter(s, i, i);
int len2 = expandAroundCenter(s, i, i + 1);
int len = Math.max(len1, len2);
if (len > end - start) {
start = i - (len - 1) / 2;
end = i + len / 2;
}
}
return s.substring(start, end + 1);
}
private int expandAroundCenter(String s, int left, int right) {
while (left >= 0 && right < s.length() && s.charAt(left) == s.charAt(right)) {
left--;
right++;
}
return right - left - 1;
}

Time Complexity: O(n²)


Practice PhonePe coding questions regularly!