As reported: Oracle front-end developer, round 1 (1.5 hours: DSA + technical), 2025 — the Longest Common Substring problem, followed by project discussion, memoization and lazy loading, scenario questions, design patterns, React hooks and core JavaScript.
Given two strings a and b, return the length of their longest common substring — the longest string that appears contiguously in both.
This is the string form of LeetCode 718 — Maximum Length of Repeated Subarray.
Example 1
a = "abcdxyz", b = "xyzabcd"
Output: 4
"abcd" appears in both.
Example 2
a = "zxabcdezy", b = "yzabcdezx"
Output: 6
"abcdez".
Example 3
a = "abc", b = "def"
Output: 0
Constraints: 0 ≤ a.length, b.length ≤ 1000; lowercase English letters.
Code runner format: one JSON value per line — a, then b. Implement longestCommonSubstring(a, b); the harness prints the length.