Coding Interview Questions

Review this list of 344 coding interview questions and answers verified by hiring managers and candidates.
  • Meta (Facebook) logoAsked at Meta (Facebook) 
    +1

    "my answer: void* memcpy(void* dest, const void* src, size_t n) { unsigned char* uDest = static_cast(dest); const unsigned char* ucSrc = static_cast(src); for(size_t i= 0; i(dest); const unsigned c"

    Srihitha J. - "my answer: void* memcpy(void* dest, const void* src, size_t n) { unsigned char* uDest = static_cast(dest); const unsigned char* ucSrc = static_cast(src); for(size_t i= 0; i(dest); const unsigned c"See full answer

    Software Engineer
    Coding
    +1 more
  • Machine Learning Engineer
    Coding
    +3 more
  • "Yes, I need to compare the first half of the first string with the reverse order of the second half of the second string. Repeat this process to the first half of the second string and the second half of the first string."

    Noor M. - "Yes, I need to compare the first half of the first string with the reverse order of the second half of the second string. Repeat this process to the first half of the second string and the second half of the first string."See full answer

    Machine Learning Engineer
    Coding
    +1 more
  • +5

    "Select interface, Count(case when issuccessfulpost then 1 end) as post_success, Count() as postattempt, ROUND((COUNT(CASE WHEN issuccessfulpost THEN 1 END) * 100 / COUNT()), 2) AS postsuccess_rate from post where interface like 'Iphone%' group by 1 order by postsuccessrate desc `"

    Richard B. - "Select interface, Count(case when issuccessfulpost then 1 end) as post_success, Count() as postattempt, ROUND((COUNT(CASE WHEN issuccessfulpost THEN 1 END) * 100 / COUNT()), 2) AS postsuccess_rate from post where interface like 'Iphone%' group by 1 order by postsuccessrate desc `"See full answer

    Data Scientist
    Coding
    +1 more
  • +12

    " from typing import Dict, List, Optional def max_profit(prices: Dict[str, int]) -> Optional[List[str]]: pass # your code goes here max = [None, 0] min = [None, float("inf")] for city, price in prices.items(): if price > max[1]: max[0], max[1] = city, price if price 0: return [min[0], max[0]] return None debug your code below prices = {'"

    Rick E. - " from typing import Dict, List, Optional def max_profit(prices: Dict[str, int]) -> Optional[List[str]]: pass # your code goes here max = [None, 0] min = [None, float("inf")] for city, price in prices.items(): if price > max[1]: max[0], max[1] = city, price if price 0: return [min[0], max[0]] return None debug your code below prices = {'"See full answer

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

  • "Was given 90 minutes with an exhaustive set of requirements to be implemented as a full-stack coding exercise. It was supposed to have a UX, a server and a database to store and retrieve data. The IDE was supposed to be self-setup before the interview. The panel asked questions on top of the implementation around decision making from a technical perspective"

    Aman G. - "Was given 90 minutes with an exhaustive set of requirements to be implemented as a full-stack coding exercise. It was supposed to have a UX, a server and a database to store and retrieve data. The IDE was supposed to be self-setup before the interview. The panel asked questions on top of the implementation around decision making from a technical perspective"See full answer

    Software Engineer
    Coding
  • Adobe logoAsked at Adobe 
    +1

    "const ops = { '+': (a, b) => a+b, '-': (a, b) => a-b, '/': (a, b) => a/b, '': (a, b) => ab, }; function calc(expr) { // Search for + or - for (let i=expr.length-1; i >= 0; i--) { const char = expr.charAt(i); if (['+', '-'].includes(char)) { return opschar), calc(expr.slice(i+1))); } } // Search for / or * for (let i=expr.length-1; i >= 0; i--) { const char = expr.charAt(i); if"

    Tiago R. - "const ops = { '+': (a, b) => a+b, '-': (a, b) => a-b, '/': (a, b) => a/b, '': (a, b) => ab, }; function calc(expr) { // Search for + or - for (let i=expr.length-1; i >= 0; i--) { const char = expr.charAt(i); if (['+', '-'].includes(char)) { return opschar), calc(expr.slice(i+1))); } } // Search for / or * for (let i=expr.length-1; i >= 0; i--) { const char = expr.charAt(i); if"See full answer

    Software Engineer
    Coding
    +3 more
  • Apple logoAsked at Apple 
    +8

    "I was able to answer this question and the follow-up questions as well"

    Anonymous Wasp - "I was able to answer this question and the follow-up questions as well"See full answer

    Software Engineer
    Coding
    +4 more
  • +9

    "from typing import List def maxprofitgreedy(stock_prices: List[int]) -> int: l=0 # buying r=1 # selling max_profit=0 while rstock_prices[l]: profit=stockprices[r]-stockprices[l] maxprofit=max(maxprofit,profit) else: l=r r+=1 return max_profit debug your code below print(maxprofitgreedy([7, 1, 5, 3, 6, 4])) `"

    Prajwal M. - "from typing import List def maxprofitgreedy(stock_prices: List[int]) -> int: l=0 # buying r=1 # selling max_profit=0 while rstock_prices[l]: profit=stockprices[r]-stockprices[l] maxprofit=max(maxprofit,profit) else: l=r r+=1 return max_profit debug your code below print(maxprofitgreedy([7, 1, 5, 3, 6, 4])) `"See full answer

    Software Engineer
    Coding
    +4 more
  • "Here is my first shot at it. Please excuse formatting. To find the maximum depth of the dependencies given a list of nodes, each having a unique string id and a list of subnodes it depends on, you can perform a depth-first search (DFS) to traverse the dependency graph. Here's how you can implement this: Represent the nodes and their dependencies using a dictionary. Perform a DFS on each node to find the maximum depth of the dependencies. Keep track of the maximum depth encountered dur"

    Tes d H. - "Here is my first shot at it. Please excuse formatting. To find the maximum depth of the dependencies given a list of nodes, each having a unique string id and a list of subnodes it depends on, you can perform a depth-first search (DFS) to traverse the dependency graph. Here's how you can implement this: Represent the nodes and their dependencies using a dictionary. Perform a DFS on each node to find the maximum depth of the dependencies. Keep track of the maximum depth encountered dur"See full answer

    Software Engineer
    Coding
    +1 more
  • "It depends on the size of the dataset. You want enough samples in both the testing, training and evaluation sets. If there is enough data, 70/20/10 is a good split"

    Jasmine Y. - "It depends on the size of the dataset. You want enough samples in both the testing, training and evaluation sets. If there is enough data, 70/20/10 is a good split"See full answer

    Coding
    Data Structures & Algorithms
  • Google logoAsked at Google 

    "def split_count(s): return 2**(len(s)-1) `"

    Steve M. - "def split_count(s): return 2**(len(s)-1) `"See full answer

    Software Engineer
    Coding
    +1 more
  • Waymo logoAsked at Waymo 
    +2

    " import pandas as pd def findaveragedistance(gps_data: pd.DataFrame) -> pd.DataFrame: #0. IMPORTANT: get the unordered pairs gpsdata['city1']=gpsdata[['origin','destination']].min(axis=1) gpsdata['city2']=gpsdata[['origin','destination']].max(axis=1) #1. get the mean distance by cities avgdistance=gpsdata.groupby(['city1','city2'], as_index=False)['distance'].mean().round(2) avgdistance.rename(columns={'distance':"averagedistance"}, inplace=True) "

    Sean L. - " import pandas as pd def findaveragedistance(gps_data: pd.DataFrame) -> pd.DataFrame: #0. IMPORTANT: get the unordered pairs gpsdata['city1']=gpsdata[['origin','destination']].min(axis=1) gpsdata['city2']=gpsdata[['origin','destination']].max(axis=1) #1. get the mean distance by cities avgdistance=gpsdata.groupby(['city1','city2'], as_index=False)['distance'].mean().round(2) avgdistance.rename(columns={'distance':"averagedistance"}, inplace=True) "See full answer

    Coding
    Data Structures & Algorithms
    +1 more
  • "1) create the experimental and control groups. 2) Then calculate the proportion (mean) of the true conversion rates for both groups using the convert column which counts True as 1 and False as 0. This is their conversion rates 3) calculate the statistic of the two groups by subtracting the proportion and standardizing. 4) get the p-value and compare with 0.05. 5) conclude the difference is statistically significant if the p-value is less than 0.05 otherwise no statistical difference"

    Frank A. - "1) create the experimental and control groups. 2) Then calculate the proportion (mean) of the true conversion rates for both groups using the convert column which counts True as 1 and False as 0. This is their conversion rates 3) calculate the statistic of the two groups by subtracting the proportion and standardizing. 4) get the p-value and compare with 0.05. 5) conclude the difference is statistically significant if the p-value is less than 0.05 otherwise no statistical difference"See full answer

    Coding
    Machine Learning
  • "While running the testloop I am getting an error RuntimeError: runningmean should contain 28 elements not 38. I think it's the difference between the categorical features in train and test. `"

    Abinash S. - "While running the testloop I am getting an error RuntimeError: runningmean should contain 28 elements not 38. I think it's the difference between the categorical features in train and test. `"See full answer

    Coding
    Machine Learning
  • Adobe logoAsked at Adobe 
    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
    Coding
    +3 more
  • Adobe logoAsked at Adobe 
    Data Engineer
    Coding
    +4 more
  • Google logoAsked at Google 
    +3

    "import time class Task: def init\(self, description, interval=None): self.description = description self.interval = interval self.next_run = time.time() class SimpleTaskScheduler: def init\(self): self.tasks = [] def add_task(self, description, interval=None): self.tasks.append(Task(description, interval)) def run(self, duration=60): end_time = time.time() + duration while time.time() < end_time: curr"

    Yash N. - "import time class Task: def init\(self, description, interval=None): self.description = description self.interval = interval self.next_run = time.time() class SimpleTaskScheduler: def init\(self): self.tasks = [] def add_task(self, description, interval=None): self.tasks.append(Task(description, interval)) def run(self, duration=60): end_time = time.time() + duration while time.time() < end_time: curr"See full answer

    Machine Learning Engineer
    Coding
    +1 more
  • Adobe logoAsked at Adobe 
    +37

    "#include // Naive method to find a pair in an array with a given sum void findPair(int nums[], int n, int target) { // consider each element except the last for (int i = 0; i < n - 1; i++) { // start from the i'th element until the last element for (int j = i + 1; j < n; j++) { // if the desired sum is found, print it if (nums[i] + nums[j] == target) { printf("Pair found (%d, %d)\n", nums[i], nums[j]); return; } } } // we reach here if the pair is not found printf("Pair not found"); } "

    Gundala tarun,cse2020 V. - "#include // Naive method to find a pair in an array with a given sum void findPair(int nums[], int n, int target) { // consider each element except the last for (int i = 0; i < n - 1; i++) { // start from the i'th element until the last element for (int j = i + 1; j < n; j++) { // if the desired sum is found, print it if (nums[i] + nums[j] == target) { printf("Pair found (%d, %d)\n", nums[i], nums[j]); return; } } } // we reach here if the pair is not found printf("Pair not found"); } "See full answer

    Software Engineer
    Coding
    +5 more
  • +7

    "with my_table as (select * , rownumber() over(order by customerid) as row_index from customers) select customer_id, customer_name from my_table where row_index % 3 = 0"

    Marcos G. - "with my_table as (select * , rownumber() over(order by customerid) as row_index from customers) select customer_id, customer_name from my_table where row_index % 3 = 0"See full answer

    Data Scientist
    Coding
    +1 more
Showing 121-140 of 344