Skip to content

Morgan Stanley Coding Questions - DSA Problems & Solutions

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

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

Morgan Stanley OA Coding Section:

  • Problems: 2-3 coding problems
  • Time: 60-90 minutes
  • Languages: C, C++, Java, Python

Question 1: Longest Increasing Subsequence

Section titled “Question 1: Longest Increasing Subsequence”
Q1: Find the length of the longest strictly increasing subsequence.

Solution (Java):

public int lengthOfLIS(int[] nums) {
int[] dp = new int[nums.length];
Arrays.fill(dp, 1);
int maxLen = 1;
for (int i = 1; i < nums.length; i++) {
for (int j = 0; j < i; j++) {
if (nums[j] < nums[i]) {
dp[i] = Math.max(dp[i], dp[j] + 1);
}
}
maxLen = Math.max(maxLen, dp[i]);
}
return maxLen;
}

Time Complexity: O(n²)


Practice Morgan Stanley coding questions regularly!