Oracle Interview Questions

Review this list of 42 Oracle interview questions and answers verified by hiring managers and candidates.
  • Oracle logoAsked at Oracle 
    Video answer for 'Generate Parentheses'
    +5

    "function generateParentheses(n) { if (n < 1) { return []; } if (n === 1) { return ["()"]; } const combinations = new Set(); let previousCombinations = generateParentheses(n-1); for (let prev of previousCombinations) { for (let i=0; i < prev.length; i++) { combinations.add(prev.slice(0, i+1) + "()" + prev.slice(i+1)); } } return [...combinations]; } `"

    Tiago R. - "function generateParentheses(n) { if (n < 1) { return []; } if (n === 1) { return ["()"]; } const combinations = new Set(); let previousCombinations = generateParentheses(n-1); for (let prev of previousCombinations) { for (let i=0; i < prev.length; i++) { combinations.add(prev.slice(0, i+1) + "()" + prev.slice(i+1)); } } return [...combinations]; } `"See full answer

    Software Engineer
    Data Structures & Algorithms
    +3 more
  • Oracle logoAsked at Oracle 
    Software Engineer
    Behavioral
  • Oracle logoAsked at Oracle 
    +8

    "Problem Statement: The Fibonacci sequence is defined as F(n) = F(n-1) + F(n-2) with F(0) = 1 and F(1) = 1. The solution is given in the problem statement itself. If the value of n = 0, return 1. If the value of n = 1, return 1. Otherwise, return the sum of data at (n - 1) and (n - 2). Explanation: The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, typically starting with 0 and 1. Java Solution: public static int fib(int n"

    Rishi G. - "Problem Statement: The Fibonacci sequence is defined as F(n) = F(n-1) + F(n-2) with F(0) = 1 and F(1) = 1. The solution is given in the problem statement itself. If the value of n = 0, return 1. If the value of n = 1, return 1. Otherwise, return the sum of data at (n - 1) and (n - 2). Explanation: The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, typically starting with 0 and 1. Java Solution: public static int fib(int n"See full answer

    Software Engineer
    Data Structures & Algorithms
    +2 more
  • Oracle logoAsked at Oracle 
    Video answer for 'Merge k sorted linked lists.'
    +6

    "A much better solution than the one in the article, below: It looks like the ones writing articles here in Javascript do not understand the time/space complexity of javascript methods. shift, splice, sort, etc... In the solution article you have a shift and a sort being done inside a while, that is, the multiplication of Ns. My solution, below, iterates through the list once and then sorts it, separately. It´s O(N+Log(N)) class ListNode { constructor(val = 0, next = null) { th"

    Guilherme F. - "A much better solution than the one in the article, below: It looks like the ones writing articles here in Javascript do not understand the time/space complexity of javascript methods. shift, splice, sort, etc... In the solution article you have a shift and a sort being done inside a while, that is, the multiplication of Ns. My solution, below, iterates through the list once and then sorts it, separately. It´s O(N+Log(N)) class ListNode { constructor(val = 0, next = null) { th"See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • +1

    "I think sliding window will work here and it is the most optimized approach to solve this question."

    Gaurav K. - "I think sliding window will work here and it is the most optimized approach to solve this question."See full answer

    Software Engineer
    Coding
    +1 more
  • 🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.

  • Oracle logoAsked at Oracle 
    Software Engineer
    Data Structures & Algorithms
    +4 more
  • Oracle logoAsked at Oracle 
    Video answer for 'Print the left view of a binary tree.'

    "Initially I asked clarifying questions like whether the tree can be empty or not and asked the interviewer to explain what is meant by left view and the explanation for the sample inputs. Then I came up with the level order traversal approach where we visit each level in the binary tree at once using a queue and at each level print the value of the first node. Interviewer seemed satisfied with the approach and asked me to code it up. Finally gave the time and space complexity of the solution."

    Ds S. - "Initially I asked clarifying questions like whether the tree can be empty or not and asked the interviewer to explain what is meant by left view and the explanation for the sample inputs. Then I came up with the level order traversal approach where we visit each level in the binary tree at once using a queue and at each level print the value of the first node. Interviewer seemed satisfied with the approach and asked me to code it up. Finally gave the time and space complexity of the solution."See full answer

    Software Engineer
  • Oracle logoAsked at Oracle 
    +5

    "bool isValidBST(TreeNode* root, long min = LONGMIN, long max = LONGMAX){ if (root == NULL) return true; if (root->val val >= max) return false; return isValidBST(root->left, min, root->val) && isValidBST(root->right, root->val, max); } `"

    Alvaro R. - "bool isValidBST(TreeNode* root, long min = LONGMIN, long max = LONGMAX){ if (root == NULL) return true; if (root->val val >= max) return false; return isValidBST(root->left, min, root->val) && isValidBST(root->right, root->val, max); } `"See full answer

    Data Engineer
    Coding
    +4 more
  • Oracle logoAsked at Oracle 
    +2

    "public class sample { public int [] merge(int [] a, int [] b) { if(a == null || a.length == 0 || b == null || b.length == 0) return null; int i = 0, j = 0, index = -1; int [] merged = new int[a.length + b.length]; while (i < a.length && j < b.length) { if(a[i] < b[i]) merged[++index] = a[i++]; else merged[++index] = b[j++]; } while (i < a.length) { merged[++index] = a[i++]; } "

    Nikhil R. - "public class sample { public int [] merge(int [] a, int [] b) { if(a == null || a.length == 0 || b == null || b.length == 0) return null; int i = 0, j = 0, index = -1; int [] merged = new int[a.length + b.length]; while (i < a.length && j < b.length) { if(a[i] < b[i]) merged[++index] = a[i++]; else merged[++index] = b[j++]; } while (i < a.length) { merged[++index] = a[i++]; } "See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • Oracle logoAsked at Oracle 
    Video answer for 'Find the minimum window substring.'

    "sliding window"

    Ashley M. - "sliding window"See full answer

    Software Engineer
    Coding
    +1 more
  • Oracle logoAsked at Oracle 
    +17

    " O(n) time, O(1) space from typing import List def maxsubarraysum(nums: List[int]) -> int: if len(nums) == 0: return 0 maxsum = currsum = nums[0] for i in range(1, len(nums)): currsum = max(currsum + nums[i], nums[i]) maxsum = max(currsum, max_sum) return max_sum debug your code below print(maxsubarraysum([-1, 2, -3, 4])) `"

    Rick E. - " O(n) time, O(1) space from typing import List def maxsubarraysum(nums: List[int]) -> int: if len(nums) == 0: return 0 maxsum = currsum = nums[0] for i in range(1, len(nums)): currsum = max(currsum + nums[i], nums[i]) maxsum = max(currsum, max_sum) return max_sum debug your code below print(maxsubarraysum([-1, 2, -3, 4])) `"See full answer

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

    "class TrieNode { constructor() { this.children = {}; this.isEndOfWord = false; } } class Trie { constructor() { this.root = new TrieNode(); } insert(word) { let node = this.root; for (const char of word) { if (!node.children[char]) { node.children[char] = new TrieNode(); } node = node.children[char]; } node.isEndOfWord = true; } search(word) { l"

    Tiago R. - "class TrieNode { constructor() { this.children = {}; this.isEndOfWord = false; } } class Trie { constructor() { this.root = new TrieNode(); } insert(word) { let node = this.root; for (const char of word) { if (!node.children[char]) { node.children[char] = new TrieNode(); } node = node.children[char]; } node.isEndOfWord = true; } search(word) { l"See full answer

    Data Engineer
    Data Structures & Algorithms
    +3 more
  • Oracle logoAsked at Oracle 
    Software Engineer
    Data Structures & Algorithms
    +2 more
  • Oracle logoAsked at Oracle 
    Machine Learning Engineer
    Data Structures & Algorithms
    +2 more
  • Oracle logoAsked at Oracle 
    +7

    "from typing import List def traprainwater(height: List[int]) -> int: if not height: return 0 l, r = 0, len(height) - 1 leftMax, rightMax = height[l], height[r] res = 0 while l < r: if leftMax < rightMax: l += 1 leftMax = max(leftMax, height[l]) res += leftMax - height[l] else: r -= 1 rightMax = max(rightMax, height[r]) "

    Anonymous Roadrunner - "from typing import List def traprainwater(height: List[int]) -> int: if not height: return 0 l, r = 0, len(height) - 1 leftMax, rightMax = height[l], height[r] res = 0 while l < r: if leftMax < rightMax: l += 1 leftMax = max(leftMax, height[l]) res += leftMax - height[l] else: r -= 1 rightMax = max(rightMax, height[r]) "See full answer

    Software Engineer
    Data Structures & Algorithms
    +4 more
  • Oracle logoAsked at Oracle 
    +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
  • Oracle logoAsked at Oracle 
    +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
  • Oracle logoAsked at Oracle 
    Software Engineer
    Data Structures & Algorithms
    +2 more
  • Oracle logoAsked at Oracle 

    "def countuniqueoutfits(totalpants: int, uniquepants: int, totalshirts: int, uniqueshirts: int, totalhats: int, uniquehats: int) -> int: """ Number of unique outfits can simply be defined by (uniquepantschoose1uniqueshirtschoose1uniquehatschoose_1) (uniquepantschoose1*uniqueshirtschoose1) # Not wearing a hat nchoosek is n """ res = (uniquepants*uniqueshirtsuniquehats) + (uniquepantsunique_shirts) return res print(countuniqueoutfits(2, 1, 1, 1, 3, 2))"

    Sai R. - "def countuniqueoutfits(totalpants: int, uniquepants: int, totalshirts: int, uniqueshirts: int, totalhats: int, uniquehats: int) -> int: """ Number of unique outfits can simply be defined by (uniquepantschoose1uniqueshirtschoose1uniquehatschoose_1) (uniquepantschoose1*uniqueshirtschoose1) # Not wearing a hat nchoosek is n """ res = (uniquepants*uniqueshirtsuniquehats) + (uniquepantsunique_shirts) return res print(countuniqueoutfits(2, 1, 1, 1, 3, 2))"See full answer

    Data Scientist
    Coding
Showing 21-40 of 42