Coding Interview Questions

Review this list of 415 coding interview questions and answers verified by hiring managers and candidates.
  • "Depend on the array size and number of 0's theere."

    Nasit S. - "Depend on the array size and number of 0's theere."See full answer

    Software Engineer
    Coding
    +1 more
  • "public static char getRepeatingCharacterInGivenString(String str){ char result = '0'; HashSet set = new HashSet(); for(int i=0;i<str.length();i++){ char c = str.charAt(i); if(!set.contains(c)){ set.add(c); } else{ result= c; break; } } return result; }"

    Sravanthi M. - "public static char getRepeatingCharacterInGivenString(String str){ char result = '0'; HashSet set = new HashSet(); for(int i=0;i<str.length();i++){ char c = str.charAt(i); if(!set.contains(c)){ set.add(c); } else{ result= c; break; } } return result; }"See full answer

    QA Engineer
    Coding
    +1 more
  • +3

    "-- Write your query here select d.departmentname, sum(o.orderamount) as total_revenue from departments d join orders o on d.departmentid = o.departmentid where o.order_date >= date('now', '-12 months') group by 1 order by 2 desc; `"

    Anonymous Roadrunner - "-- Write your query here select d.departmentname, sum(o.orderamount) as total_revenue from departments d join orders o on d.departmentid = o.departmentid where o.order_date >= date('now', '-12 months') group by 1 order by 2 desc; `"See full answer

    Coding
    SQL
  • Frontend Engineer
    Coding
    +1 more
  • +5

    "function getDifferentNumberImmutable(arr) { const exists = new Array(arr.length).fill(false); for (let item of arr) { exists[item] = true; } for (let i=0; i < exists.length; i++) { if (!exists[i]) { return i; } } return arr.length; } function getDifferentNumber(arr) { let i=0; while (i < arr.length) { while (arr[i] < arr.length && arr[i] !== i) { // switch (arr[i] and arr[arr[i]]) const j = arr[i]; const temp = arr[j]; arr[j]"

    Tiago R. - "function getDifferentNumberImmutable(arr) { const exists = new Array(arr.length).fill(false); for (let item of arr) { exists[item] = true; } for (let i=0; i < exists.length; i++) { if (!exists[i]) { return i; } } return arr.length; } function getDifferentNumber(arr) { let i=0; while (i < arr.length) { while (arr[i] < arr.length && arr[i] !== i) { // switch (arr[i] and arr[arr[i]]) const j = arr[i]; const temp = arr[j]; arr[j]"See full answer

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

  • Coding
    Data Structures & Algorithms
  • +3

    "SELECT DISTINCT title, ROUND(AVG(rating) over (partition by title),1) avg_rating, ROUND(AVG(rating) over (partition by genre),1) genre_rating FROM rating r JOIN movie m ON r.movieid=m.movieid ORDER by 1"

    Harshi B. - "SELECT DISTINCT title, ROUND(AVG(rating) over (partition by title),1) avg_rating, ROUND(AVG(rating) over (partition by genre),1) genre_rating FROM rating r JOIN movie m ON r.movieid=m.movieid ORDER by 1"See full answer

    Coding
    SQL
  • Adobe logoAsked at Adobe 
    +7

    "function trapRainWater(height) { if (height.length = leftTrap || leftPosition >= heightLimit) { leftTrap = leftPosition; heightLimit = Math.min(le"

    Tiago R. - "function trapRainWater(height) { if (height.length = leftTrap || leftPosition >= heightLimit) { leftTrap = leftPosition; heightLimit = Math.min(le"See full answer

    Software Engineer
    Coding
    +4 more
  • Asked at Confluent 

    "This depends on the list of documents and the length of the documents. My implementation will use Trie with node containing the following: class TrieNode { is_end: boolean, instances: { docid → [wordpositions] }, children: array[26] } Look up for a word will give result instances{docid:wordposition...} dictionary (which can be further improved by methods like max instance on a document....you name it...) Trie space is proportional to the total characters in"

    Aelaf G. - "This depends on the list of documents and the length of the documents. My implementation will use Trie with node containing the following: class TrieNode { is_end: boolean, instances: { docid → [wordpositions] }, children: array[26] } Look up for a word will give result instances{docid:wordposition...} dictionary (which can be further improved by methods like max instance on a document....you name it...) Trie space is proportional to the total characters in"See full answer

    Software Engineer
    Coding
    +1 more
  • Software Engineer
    Coding
    +1 more
  • Nvidia logoAsked at Nvidia 

    "virtual function is a member function declared with virtual keyword in a base class. It enables derived classes to redefine this function with their own specific implementations."

    Sonia M. - "virtual function is a member function declared with virtual keyword in a base class. It enables derived classes to redefine this function with their own specific implementations."See full answer

    Software Engineer
    Coding
    +1 more
  • Adobe logoAsked at Adobe 

    Permutations

    IDE
    Medium

    "function permute(nums) { if (nums.length <= 1) { return [nums]; } const prevPermutations = permute(nums.slice(0, nums.length-1)); const currentNum = nums[nums.length-1]; const permutations = new Set(); for (let prev of prevPermutations) { for (let i=0; i < prev.length; i++) { permutations.add([...prev.slice(0, i), currentNum, ...prev.slice(i)]); } permutations.add([...prev, currentNum]); } return [...permutations]"

    Tiago R. - "function permute(nums) { if (nums.length <= 1) { return [nums]; } const prevPermutations = permute(nums.slice(0, nums.length-1)); const currentNum = nums[nums.length-1]; const permutations = new Set(); for (let prev of prevPermutations) { for (let i=0; i < prev.length; i++) { permutations.add([...prev.slice(0, i), currentNum, ...prev.slice(i)]); } permutations.add([...prev, currentNum]); } return [...permutations]"See full answer

    Software Engineer
    Coding
    +3 more
  • +1

    "SELECT COUNT(*) unique_conversations FROM messenger_sends WHERE senderid < receiverid"

    Lucas G. - "SELECT COUNT(*) unique_conversations FROM messenger_sends WHERE senderid < receiverid"See full answer

    Coding
    SQL
  • "too many questions for clarification on this to start"

    Steven S. - "too many questions for clarification on this to start"See full answer

    Coding
    SQL
  • Nvidia logoAsked at Nvidia 

    "def containSubString(mainString, SubString): s1 = "hello world" # main String s2 = "hello" s3 = "world" s4 = "Nothing" answer1 = containSubString(s1, s2) answer2 = containSubString(s1, s3) answer3 = containSubString(s1, s4) print(answer1 , answer2, answer) "

    Jalpa S. - "def containSubString(mainString, SubString): s1 = "hello world" # main String s2 = "hello" s3 = "world" s4 = "Nothing" answer1 = containSubString(s1, s2) answer2 = containSubString(s1, s3) answer3 = containSubString(s1, s4) print(answer1 , answer2, answer) "See full answer

    Software Engineer
    Coding
    +1 more
  • "This problem can be solved with two approaches Iterative approach Recursive approach Quite easy to think about the iterative approach, you can make use of a while loop in that case. But what if you want to make use of previously computed values? That case going for the recursive solution is quite useful. class Collatz: def init(self) -> None: self.cache = {} self.steps = 0 def steps_from(self, n) -> int: # base case if n == 1: "

    Frederick A. - "This problem can be solved with two approaches Iterative approach Recursive approach Quite easy to think about the iterative approach, you can make use of a while loop in that case. But what if you want to make use of previously computed values? That case going for the recursive solution is quite useful. class Collatz: def init(self) -> None: self.cache = {} self.steps = 0 def steps_from(self, n) -> int: # base case if n == 1: "See full answer

    Software Engineer
    Coding
  • Coding
    Data Structures & Algorithms
  • Robinhood logoAsked at Robinhood 

    "Assuming that trades will have information like trade_type buy or sell trade_price with these tuples, one can iterate over each trade while maintaining a stack which maintains all the open buy trades. If we encounter a sell trade then we pop one element make it a buy/sell pair and calculate the profit/loss for that pair. Moreover, keep adding pair-wise profit/loss to calculate overall profit as we continue iterating over trades. At the end print pairs and their profit/loss along with"

    Parth S. - "Assuming that trades will have information like trade_type buy or sell trade_price with these tuples, one can iterate over each trade while maintaining a stack which maintains all the open buy trades. If we encounter a sell trade then we pop one element make it a buy/sell pair and calculate the profit/loss for that pair. Moreover, keep adding pair-wise profit/loss to calculate overall profit as we continue iterating over trades. At the end print pairs and their profit/loss along with"See full answer

    Coding
    Data Structures & Algorithms
    +1 more
  • Meta (Facebook) logoAsked at Meta (Facebook) 

    "Coded the solution using this approach that is frequency table and counting. it is Leetcode 791"

    Anonymous Porcupine - "Coded the solution using this approach that is frequency table and counting. it is Leetcode 791"See full answer

    Mobile Engineer
    Coding
  • Visa logoAsked at Visa 
    Software Engineer
    Coding
    +1 more
Showing 261-280 of 415