Skip to main content

Coding Interview Questions

Review this list of 137 interview questions and answers verified by hiring managers and candidates.
  • 5 answers
    +2

    "WITH CTE AS ( SELECT *, ROWNUMBER()OVER(PARTITION BY utxoid ORDER BY transactionid) AS trxrk FROM transactions JOIN transaction_inputs USING (transaction_id) JOIN utxo USING (utxo_id) ) SELECT transaction_id AS InvalidTransactionId FROM CTE WHERE sender!=address OR trx_rk > 1 `"

    E L. - "WITH CTE AS ( SELECT *, ROWNUMBER()OVER(PARTITION BY utxoid ORDER BY transactionid) AS trxrk FROM transactions JOIN transaction_inputs USING (transaction_id) JOIN utxo USING (utxo_id) ) SELECT transaction_id AS InvalidTransactionId FROM CTE WHERE sender!=address OR trx_rk > 1 `"See full answer

    Coding
    SQL
  • 4 answers
    +1

    "-- Write your query here select count(distinct o.customer_id) as customers, d.department_name from orders o join departments d using (department_id) where extract(year from o.order_date) = 2022 and d.department_name in ('Electronics', 'Fashion') group by 2; `"

    Anonymous Roadrunner - "-- Write your query here select count(distinct o.customer_id) as customers, d.department_name from orders o join departments d using (department_id) where extract(year from o.order_date) = 2022 and d.department_name in ('Electronics', 'Fashion') group by 2; `"See full answer

    Coding
    SQL
  • 4 answers
    +1

    "with ranking_table as ( select player_name, score, rank() over (order by score desc) as ranking from players ) select player_name, score, ranking from ranking_table where ranking in (4,6,11)"

    מאיה ט. - "with ranking_table as ( select player_name, score, rank() over (order by score desc) as ranking from players ) select player_name, score, ranking from ranking_table where ranking in (4,6,11)"See full answer

    Coding
    SQL
  • 2 answers

    " 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
  • Apple logoAsked at Apple 
    9 answers
    +5

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

  • 4 answers

    " import pandas as pd import numpy as np def findoverstretchedemployees(departments: pd.DataFrame, employees: pd.DataFrame, projects: pd.DataFrame, employees_projects: pd.DataFrame) -> pd.DataFrame: Make a copy to avoid modifying original dataframe projects = projects.copy() Convert dates to datetime projects["startdate"] = pd.todatetime(projects["start_date""

    Diyorbek T. - " import pandas as pd import numpy as np def findoverstretchedemployees(departments: pd.DataFrame, employees: pd.DataFrame, projects: pd.DataFrame, employees_projects: pd.DataFrame) -> pd.DataFrame: Make a copy to avoid modifying original dataframe projects = projects.copy() Convert dates to datetime projects["startdate"] = pd.todatetime(projects["start_date""See full answer

    Data Analyst
    Coding
    +1 more
  • Apple logoAsked at Apple 

    Coin Change

    IDE
    Medium
    12 answers
    +9

    "The example given is wrong. The 2nd test case should have answer 3, as we can get to 6 by using 3 coins of denomination 2."

    Anmol R. - "The example given is wrong. The 2nd test case should have answer 3, as we can get to 6 by using 3 coins of denomination 2."See full answer

    Software Engineer
    Coding
    +4 more
  • Adobe logoAsked at Adobe 
    9 answers
    +6

    "Less efficient version, yet effective for the interview: def is_palindrome(s: str) -> bool: dim = len(s) if dim str: dim = len(s) if dim < 2: return s left = 0 longest = "" while left < dim: righ"

    Gabriele G. - "Less efficient version, yet effective for the interview: def is_palindrome(s: str) -> bool: dim = len(s) if dim str: dim = len(s) if dim < 2: return s left = 0 longest = "" while left < dim: righ"See full answer

    Machine Learning Engineer
    Data Structures & Algorithms
    +3 more
  • Snap logoAsked at Snap 
    2 answers

    "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
  • 4 answers
    +1

    "The question is incomplete --- the code only passes if you return the data frame sorted by BOTH department name AND rank. While in the problem description, it mentions to only rank by department name: "The results should be ordered by department name." Not a big difference I know, but students shouldn't need to look into the solution to get the necessary knowledge to answer the question."

    Chao peter Y. - "The question is incomplete --- the code only passes if you return the data frame sorted by BOTH department name AND rank. While in the problem description, it mentions to only rank by department name: "The results should be ordered by department name." Not a big difference I know, but students shouldn't need to look into the solution to get the necessary knowledge to answer the question."See full answer

    Coding
    Data Analysis
  • 1 answer

    "Table user is empy....... Problem with this problem "

    Gabriella F. - "Table user is empy....... Problem with this problem "See full answer

    Coding
    SQL
  • 3 answers

    " import pandas as pd def findimprovingstudents(transcript: pd.DataFrame) -> pd.DataFrame: summary = transcript.pivottable(index='studentid', values = 'yearlygpa', aggfunc = 'sum',columns = 'year').resetindex() summary['average_gpa'] = round((summary[2023] + summary[2022] + summary[2021])/3,2) return summary(summary[2023] > summary[2022]) & (summary[2022] > summary[2021])] #yn > yn-1, yn-1 > yn-2, yn-3 debug your co"

    Caleb S. - " import pandas as pd def findimprovingstudents(transcript: pd.DataFrame) -> pd.DataFrame: summary = transcript.pivottable(index='studentid', values = 'yearlygpa', aggfunc = 'sum',columns = 'year').resetindex() summary['average_gpa'] = round((summary[2023] + summary[2022] + summary[2021])/3,2) return summary(summary[2023] > summary[2022]) & (summary[2022] > summary[2021])] #yn > yn-1, yn-1 > yn-2, yn-3 debug your co"See full answer

    Coding
    Data Analysis
  • Oracle logoAsked at Oracle 
    3 answers

    "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
  • 2 answers

    " 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

    Coding
    Data Analysis
  • Add answer
    Data Analyst
    Coding
    +1 more
  • Add answer
    Coding
  • Add answer
    Coding
Showing 121-137 of 137