Data Structures & Algorithms Interview Questions

Review this list of 65 data structures & algorithms interview questions and answers verified by hiring managers and candidates.
  • Adobe logoAsked at Adobe 

    "func isMatch(text: String, pattern: String) -> Bool { // Convert strings to arrays for easier indexing let s = Array(text.characters) let p = Array(pattern.characters) guard !s.isEmpty && !p.isEmpty else { return true } // Create DP table: dpi represents if s[0...i-1] matches p[0...j-1] var dp = Array(repeating: Array(repeating: false, count: p.count + 1), count: s.count + 1) // Empty pattern matches empty string dp[0]["

    Vince S. - "func isMatch(text: String, pattern: String) -> Bool { // Convert strings to arrays for easier indexing let s = Array(text.characters) let p = Array(pattern.characters) guard !s.isEmpty && !p.isEmpty else { return true } // Create DP table: dpi represents if s[0...i-1] matches p[0...j-1] var dp = Array(repeating: Array(repeating: false, count: p.count + 1), count: s.count + 1) // Empty pattern matches empty string dp[0]["See full answer

    Machine Learning Engineer
    Data Structures & Algorithms
    +3 more
  • " function diffBetweenTwoStrings(source, target) { /** @param source: string @param target: string @return: string[] */ let dp = new Array(source.length+1).fill().map(() => Array(target.length+1).fill(0)) for (let i = source.length; i>= 0; i--) { for (let j = target.length; j>= 0; j--) { if (i === source.length) { dpi = target.length - j } else if (j === target.length) { dpi = sou"

    Matthew K. - " function diffBetweenTwoStrings(source, target) { /** @param source: string @param target: string @return: string[] */ let dp = new Array(source.length+1).fill().map(() => Array(target.length+1).fill(0)) for (let i = source.length; i>= 0; i--) { for (let j = target.length; j>= 0; j--) { if (i === source.length) { dpi = target.length - j } else if (j === target.length) { dpi = sou"See full answer

    Data Structures & Algorithms
    Coding
  • Adobe logoAsked at Adobe 
    +6

    "function isPalindrome(s, start, end) { while (s[start] === s[end] && end >= start) { start++; end--; } return end <= start; } function longestPalindromicSubstring(s) { let longestPalindrome = ''; for (let i=0; i < s.length; i++) { let j = s.length-1; while (s[i] !== s[j] && i <= j) { j--; } if (s[i] === s[j]) { if (isPalindrome(s, i, j)) { const validPalindrome = s.substring(i, j+1"

    Tiago R. - "function isPalindrome(s, start, end) { while (s[start] === s[end] && end >= start) { start++; end--; } return end <= start; } function longestPalindromicSubstring(s) { let longestPalindrome = ''; for (let i=0; i < s.length; i++) { let j = s.length-1; while (s[i] !== s[j] && i <= j) { j--; } if (s[i] === s[j]) { if (isPalindrome(s, i, j)) { const validPalindrome = s.substring(i, j+1"See full answer

    Data Engineer
    Data Structures & Algorithms
    +3 more
  • Apple logoAsked at Apple 
    +2

    "Make current as root. 2 while current is not null, if p and q are less than current, go left. If p and q are greater than current, go right. else return current. return null"

    Vaibhav D. - "Make current as root. 2 while current is not null, if p and q are less than current, go left. If p and q are greater than current, go right. else return current. return null"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • Snap logoAsked at Snap 

    "public Double calculateRatio(String source, String destination) { Double ratio=1.0; while(graph.containsKey(source) && !visited.contains(source)) { visited.add(source); Map valueMap=graph.get(source); if(valueMap.containsKey(destination)) { return ratio*=valueMap.get(destination); } Map.Entry firstEntry=valueMap.entrySet().iterator().next(); source=firstEntry.getKey(); ratio*=firstEntry.getValue(); System.out.println("Entered"); } return null; }"

    Divya R. - "public Double calculateRatio(String source, String destination) { Double ratio=1.0; while(graph.containsKey(source) && !visited.contains(source)) { visited.add(source); Map valueMap=graph.get(source); if(valueMap.containsKey(destination)) { return ratio*=valueMap.get(destination); } Map.Entry firstEntry=valueMap.entrySet().iterator().next(); source=firstEntry.getKey(); ratio*=firstEntry.getValue(); System.out.println("Entered"); } return null; }"See full answer

    Software Engineer
    Data Structures & Algorithms
    +2 more
  • 🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.

Showing 61-65 of 65