Hi everyone,
I'm new to Angular development and I'm struggling with interview questions related to the framework. I've read through all of the documentation and angular article and tutorials I can find but I still feel really lost when it comes to coding challenges.
For example, I was recently asked to write a function that takes two strings and returns the longest common substring between them. I wrote the following code, but it's not working correctly - can someone please help me figure out where I'm going wrong?
JavaScript
function longestCommonSubstring(string1, string2) {
let longestSubstring = '';
for (let i = 0; i longestSubstring.length)
Amit MohantyRank #112 · 20K reputationPosted Mar 30, 2023, 2:45 AM EDT
function findLongestCommonSubstring(str1: string, str2: string): string { let longestCommonSubstring = ''; let table: number[][] = []; for (let i = 0; i longestCommonSubstring.length) { longestCommonSubstring = str1.slice(i - table[i][j], i); } } else { table[i][j] = 0; } } } return longestCommonSubstring; }Rajkiran SwainRank #165 · 14.4K reputationPosted Mar 30, 2023, 2:28 AM EDT
function longestCommonSubstring(string1, string2) { let longestSubstring = ''; for (let i = 0; i longestSubstring.length) { longestSubstring = currentSubstring; } } } return longestSubstring; }