Coding Interview Questions

Review this list of 344 coding interview questions and answers verified by hiring managers and candidates.
  • LinkedIn logoAsked at LinkedIn 
    Software Engineer
    Coding
    +2 more
  • Apple logoAsked at Apple 

    "Function that transforms each elements in a collection and returns new collection with transformed elements"

    Susmita S. - "Function that transforms each elements in a collection and returns new collection with transformed elements"See full answer

    Software Engineer
    Coding
    +1 more
  • "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
    Coding
    +2 more
  • Adobe logoAsked at Adobe 

    "Leetcode 347: Heap + Hashtable Follow up question: create heap with the length of K instead of N (more time complexity but less space )"

    Chen J. - "Leetcode 347: Heap + Hashtable Follow up question: create heap with the length of K instead of N (more time complexity but less space )"See full answer

    Data Engineer
    Coding
    +3 more
  • "I try to solve this initially using quick select where will take a pivot element and position the remaining elements and check if the current index is answer or not and continue the same but it requires o(n*n), but interviewee is expecting the best from me, so at the end i tried solving using heaps where will check the difference between k and n-k to use min or max heap after that we will heap the array, and will keep popping the element k-1 and return the peek one which leads to answer."

    Mourya C. - "I try to solve this initially using quick select where will take a pivot element and position the remaining elements and check if the current index is answer or not and continue the same but it requires o(n*n), but interviewee is expecting the best from me, so at the end i tried solving using heaps where will check the difference between k and n-k to use min or max heap after that we will heap the array, and will keep popping the element k-1 and return the peek one which leads to answer."See full answer

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

  • Meta (Facebook) logoAsked at Meta (Facebook) 
    Machine Learning Engineer
    Coding
    +1 more
  • " import pandas as pd from datetime import datetime def findfastestlike(log: pd.DataFrame) -> pd.DataFrame: log=log.sortvalues(['userid','timestamp']) #get the prev event, time by user log['prevevent'] = log.groupby('userid')['event'].shift(1) log['prevtimestamp'] = log.groupby('userid')['timestamp'].shift(1) True only on rows where the previous event was a login and the current event is a like log['loginlike'] = (log['prevevent'] == 'log"

    Sean L. - " import pandas as pd from datetime import datetime def findfastestlike(log: pd.DataFrame) -> pd.DataFrame: log=log.sortvalues(['userid','timestamp']) #get the prev event, time by user log['prevevent'] = log.groupby('userid')['event'].shift(1) log['prevtimestamp'] = log.groupby('userid')['timestamp'].shift(1) True only on rows where the previous event was a login and the current event is a like log['loginlike'] = (log['prevevent'] == 'log"See full answer

    Data Scientist
    Coding
    +2 more
  • " debug your code below departments = pd.DataFrame({ 'id': [1, 2, 3, 4, 5], 'name': ['Reporting', 'Engineering', 'Marketing', 'Biz Dev', 'Silly Walks'] }) employees = pd.DataFrame({ 'id': [1, 2, 3, 4, 5, 6], 'first_name': ['John', 'Ava', 'Cailin', 'Mike', 'Ian', 'John'], 'last_name': ['Smith', 'Muffinson', 'Ninson', 'Peterson', 'Peterson', 'Mills'], 'salary': [20000, 10000, 30000, 20000, 80000, 50000], 'department_id': [1, 5, 2, 2, 2, 3] }) projects = p"

    Sean L. - " debug your code below departments = pd.DataFrame({ 'id': [1, 2, 3, 4, 5], 'name': ['Reporting', 'Engineering', 'Marketing', 'Biz Dev', 'Silly Walks'] }) employees = pd.DataFrame({ 'id': [1, 2, 3, 4, 5, 6], 'first_name': ['John', 'Ava', 'Cailin', 'Mike', 'Ian', 'John'], 'last_name': ['Smith', 'Muffinson', 'Ninson', 'Peterson', 'Peterson', 'Mills'], 'salary': [20000, 10000, 30000, 20000, 80000, 50000], 'department_id': [1, 5, 2, 2, 2, 3] }) projects = p"See full answer

    Data Scientist
    Coding
    +2 more
  • Uber logoAsked at Uber 
    Machine Learning Engineer
    Coding
    +1 more
  • Apple logoAsked at Apple 

    "filter function usually exists in some high level programming that adopt FP paradigm. It taks a sequence of items and a predicate function, and returns (conceptually) a subset of the items that satisfy the predicate. Adopt this kind of operation (filter, map, reduce, take, pairwise ...) can help writting cleaner code, and reduce the usage of mutable part in the program, lower the possibility of making human mistake. Take Python for example (although const-ness is not exists in Python), assu"

    Weida H. - "filter function usually exists in some high level programming that adopt FP paradigm. It taks a sequence of items and a predicate function, and returns (conceptually) a subset of the items that satisfy the predicate. Adopt this kind of operation (filter, map, reduce, take, pairwise ...) can help writting cleaner code, and reduce the usage of mutable part in the program, lower the possibility of making human mistake. Take Python for example (although const-ness is not exists in Python), assu"See full answer

    Software Engineer
    Coding
    +1 more
  • Apple logoAsked at Apple 
    Software Engineer
    Coding
    +1 more
  • Software Engineer
    Coding
    +1 more
  • Software Engineer
    Coding
    +1 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
  • LinkedIn logoAsked at LinkedIn 

    "Count how many 1 and 2. calculate how many remaining items with '0'. Override existing data with knowledge of how many '0','1','2' in that order; TC=O(n), SC=O(1)"

    Konstantin P. - "Count how many 1 and 2. calculate how many remaining items with '0'. Override existing data with knowledge of how many '0','1','2' in that order; TC=O(n), SC=O(1)"See full answer

    Coding
    Data Structures & Algorithms
    +1 more
  • Apple logoAsked at Apple 
    Software Engineer
    Coding
    +1 more
  • Apple logoAsked at Apple 
    Software Engineer
    Coding
    +1 more
  • Salesforce logoAsked at Salesforce 
    Software Engineer
    Coding
    +1 more
  • "Run length encoding. This will preserve order of values in vector."

    Yash S. - "Run length encoding. This will preserve order of values in vector."See full answer

    Coding
    Data Structures & Algorithms
    +1 more
  • Nvidia logoAsked at Nvidia 
    Software Engineer
    Coding
    +1 more
Showing 301-320 of 344