Coding Interview Questions

Review this list of 363 coding interview questions and answers verified by hiring managers and candidates.
  • Apple logoAsked at Apple 

    "class Trie { private TrieNode root; public Trie() { root = new TrieNode(); } public void insert(String word) { TrieNode temp=root; for(int i=0; i<word.length(); i++) { if(!temp.children.containsKey(word.charAt(i))) { temp.children.put(word.charAt(i), new TrieNode()); } temp=temp.children.get(word.charAt(i)); } temp.isEndOfWord=true; } public boolean search(String word) { TrieNode temp=root; for(int i=0; i<word.length(); i++) { if(!temp.children.containsKey(word.charAt(i))) { return false; } temp"

    Divya R. - "class Trie { private TrieNode root; public Trie() { root = new TrieNode(); } public void insert(String word) { TrieNode temp=root; for(int i=0; i<word.length(); i++) { if(!temp.children.containsKey(word.charAt(i))) { temp.children.put(word.charAt(i), new TrieNode()); } temp=temp.children.get(word.charAt(i)); } temp.isEndOfWord=true; } public boolean search(String word) { TrieNode temp=root; for(int i=0; i<word.length(); i++) { if(!temp.children.containsKey(word.charAt(i))) { return false; } temp"See full answer

    Data Engineer
    Coding
    +3 more
  • "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
  • +6

    "Good Question, but I would've marked this as medium not hard difficulty, since it's just a straightforward traversal."

    Ahmed A. - "Good Question, but I would've marked this as medium not hard difficulty, since it's just a straightforward traversal."See full answer

    Coding
    Data Structures & Algorithms
  • +1

    "-- 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
  • 🧠 Want an expert answer to a question? Saving questions lets us know what content to make next.

  • 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
  • Adobe logoAsked at Adobe 
    Machine Learning Engineer
    Coding
    +2 more
  • +2

    "select DISTINCT p.product_id, p.product_name , CASE when sale_date is null then 'Not Sold' else 'Sold' END as sale_status from products p left join sales s on p.productid= s.productid `"

    Gowtami K. - "select DISTINCT p.product_id, p.product_name , CASE when sale_date is null then 'Not Sold' else 'Sold' END as sale_status from products p left join sales s on p.productid= s.productid `"See full answer

    Coding
    SQL
  • 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
  • +1

    "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
  • "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
  • Meta (Facebook) logoAsked at Meta (Facebook) 
    Software Engineer
    Coding
    +1 more
  • Software Engineer
    Coding
    +1 more
  • Salesforce logoAsked at Salesforce 

    "Bitshift the number to the right and keep track of the 1's you encounter. If you bitshift it completely and only encounter one 1, it is a power of two."

    Nils G. - "Bitshift the number to the right and keep track of the 1's you encounter. If you bitshift it completely and only encounter one 1, it is a power of two."See full answer

    Software Engineer
    Coding
    +1 more
  • Meta (Facebook) logoAsked at Meta (Facebook) 
    Video answer for 'Find the common ancestors in a tree.'
    Machine Learning Engineer
    Coding
    +1 more
  • Asked at Confluent 
    Software Engineer
    Coding
    +1 more
  • Nvidia logoAsked at Nvidia 

    "Function that is passed as an argument or parameter to another function and it gets executed when the function that it is passed to gets executed"

    Susmita S. - "Function that is passed as an argument or parameter to another function and it gets executed when the function that it is passed to gets executed"See full answer

    Software Engineer
    Coding
    +1 more
  • "Construct a min-heap either inplace, or by making a copy of the array and then applying heapify on that copy. This is done in O(n) time. Maintain two zero-initialised variables - sum and count. Keep popping off the heap while sum < k, and update count. In the worst case you will have to do n pops, and each pop is O(log n), so the algorithm would take O(n log n) in total. Space complexity depends on whether you're allowed to modify inplace or not, so either O(1) or O(n) respectively."

    Anonymous Wolf - "Construct a min-heap either inplace, or by making a copy of the array and then applying heapify on that copy. This is done in O(n) time. Maintain two zero-initialised variables - sum and count. Keep popping off the heap while sum < k, and update count. In the worst case you will have to do n pops, and each pop is O(log n), so the algorithm would take O(n log n) in total. Space complexity depends on whether you're allowed to modify inplace or not, so either O(1) or O(n) respectively."See full answer

    Software Engineer
    Coding
    +1 more
  • Adobe logoAsked at Adobe 

    Permutations

    IDE
    Medium

    " import java.util.*; import java.util.stream.Collectors; class Solution { public static List> permute(int[] nums) { List> resList=new ArrayList(); List list=new ArrayList(); Set visited=new HashSet(); permute(nums, resList, list, visited); return resList; } public static void permute(int[] nums, List> resList, List list, Set visited) { if(vis"

    Divya R. - " import java.util.*; import java.util.stream.Collectors; class Solution { public static List> permute(int[] nums) { List> resList=new ArrayList(); List list=new ArrayList(); Set visited=new HashSet(); permute(nums, resList, list, visited); return resList; } public static void permute(int[] nums, List> resList, List list, Set visited) { if(vis"See full answer

    Software Engineer
    Coding
    +3 more
Showing 221-240 of 363