Coding Interview Questions

Review this list of 374 coding interview questions and answers verified by hiring managers and candidates.
  • 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
  • +6

    "productssold = set(transactions['productid']) unsoldproducts = products.loc[~products['id'].isin(productssold)] return unsold_products[["id", "name", "stock"]] `"

    Laura U. - "productssold = set(transactions['productid']) unsoldproducts = products.loc[~products['id'].isin(productssold)] return unsold_products[["id", "name", "stock"]] `"See full answer

    Coding
    Data Analysis
  • "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
  • Adobe logoAsked at Adobe 
    Software Engineer
    Coding
    +4 more
  • Google logoAsked at Google 
    +5

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

  • +18

    "def validateIP(ip): """ @param ip: str @return: bool """ \# ip needs to be in X.X.X.X \# X is from 0 to 255 \# split the ip at "." split = ip.split('.') if (len(split) != 4): return False for number in split: if (int(number) 255): return False return True"

    Anonymous Owl - "def validateIP(ip): """ @param ip: str @return: bool """ \# ip needs to be in X.X.X.X \# X is from 0 to 255 \# split the ip at "." split = ip.split('.') if (len(split) != 4): return False for number in split: if (int(number) 255): return False return True"See full answer

    Coding
    Data Structures & Algorithms
  • "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."

    Anonymous Condor - "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
  • +8

    "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

    Coding
    SQL
  • 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
  • Apple logoAsked at Apple 
    +4

    "public static void sortBinaryArray(int[] array) { int len = array.length; int[] res = new int[len]; int r=len-1; for (int value : array) { if(value==1){ res[r]= 1; r--; } } System.out.println(Arrays.toString(res)); } `"

    Nitin P. - "public static void sortBinaryArray(int[] array) { int len = array.length; int[] res = new int[len]; int r=len-1; for (int value : array) { if(value==1){ res[r]= 1; r--; } } System.out.println(Arrays.toString(res)); } `"See full answer

    Software Engineer
    Coding
    +1 more
  • Adobe logoAsked at Adobe 
    Data Engineer
    Coding
    +4 more
  • +7

    "-- Write your query here With base as( select player_name , team_id , max(scores.gamescore) as gamescore from players join scores on players.playerid = scores.playerid group by playername, teamid) Select team_id , player_name , game_score from ( Select teamid , playername ,gamescore, DenseRank() Over (Partition by teamid order by gamescore desc ) as rnk from base) a where rnk <=2 `"

    Palak S. - "-- Write your query here With base as( select player_name , team_id , max(scores.gamescore) as gamescore from players join scores on players.playerid = scores.playerid group by playername, teamid) Select team_id , player_name , game_score from ( Select teamid , playername ,gamescore, DenseRank() Over (Partition by teamid order by gamescore desc ) as rnk from base) a where rnk <=2 `"See full answer

    Coding
    SQL
  • "Use an index, two pointers, and a set to keep track of elements that you've seen. pseudo code follows: for i, elem in enumerate(array): if elem in set return False if i > N: set.remove(array[i-N])"

    Michael B. - "Use an index, two pointers, and a set to keep track of elements that you've seen. pseudo code follows: for i, elem in enumerate(array): if elem in set return False if i > N: set.remove(array[i-N])"See full answer

    Machine Learning Engineer
    Coding
  • "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
  • +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

    Coding
    SQL
  • +14

    "function insertItem(heap, item) { heap.push(item); if (heap.length > 0) { let current = heap.length - 1; while(current > 0 && heap[Math.floor(current/2)] > heap[current]) { [heap[Math.floor(current/2)], heap[current]] = [heap[current], heap[Math.floor(current/2)]]; current = Math.floor(current/2); } } } function extractMin(heap) { let smallest = heap[0]; let len = heap.length; if (len > 2) { heap[0] = heap[len - 1]; heap.splice(len - 1); "

    Arturo Z. - "function insertItem(heap, item) { heap.push(item); if (heap.length > 0) { let current = heap.length - 1; while(current > 0 && heap[Math.floor(current/2)] > heap[current]) { [heap[Math.floor(current/2)], heap[current]] = [heap[current], heap[Math.floor(current/2)]]; current = Math.floor(current/2); } } } function extractMin(heap) { let smallest = heap[0]; let len = heap.length; if (len > 2) { heap[0] = heap[len - 1]; heap.splice(len - 1); "See full answer

    Coding
    Data Structures & Algorithms
  • "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 
    +9

    "Problem Statement: The Fibonacci sequence is defined as F(n) = F(n-1) + F(n-2) with F(0) = 1 and F(1) = 1. The solution is given in the problem statement itself. If the value of n = 0, return 1. If the value of n = 1, return 1. Otherwise, return the sum of data at (n - 1) and (n - 2). Explanation: The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, typically starting with 0 and 1. Java Solution: public static int fib(int n"

    Rishi G. - "Problem Statement: The Fibonacci sequence is defined as F(n) = F(n-1) + F(n-2) with F(0) = 1 and F(1) = 1. The solution is given in the problem statement itself. If the value of n = 0, return 1. If the value of n = 1, return 1. Otherwise, return the sum of data at (n - 1) and (n - 2). Explanation: The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, typically starting with 0 and 1. Java Solution: public static int fib(int n"See full answer

    Software Engineer
    Coding
    +2 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
  • "You are given a string S and a number K as input, and your task is to print S to console output considering that, at most, you can print K characters per line. Example: S = "abracadabra sample" K = 11 Output: abracadabra sample Note that this problem requires the interviewee gather extra requirements from the interviewer (e.g. do we care about multiple white spaces? what if the length of a word is greater than K, ...)"

    B. T. - "You are given a string S and a number K as input, and your task is to print S to console output considering that, at most, you can print K characters per line. Example: S = "abracadabra sample" K = 11 Output: abracadabra sample Note that this problem requires the interviewee gather extra requirements from the interviewer (e.g. do we care about multiple white spaces? what if the length of a word is greater than K, ...)"See full answer

    Software Engineer
    Coding
    +1 more
Showing 141-160 of 374