Currying is the process by which a function of N arguments is implemented as N single-argument functions such that first of them takes in the first argument and returns a function which takes in the 2nd argument and so on, until the Nth single-argument function finally returns the value of the multi-argument function being implemented.
You're an industrious programmer that lives off the grid. The local well that you use to fetch water has gone dry, so you've decided to collect rain water to filter; however, your collection device isn't flat.
You are given an array of non-negative integers representing an elevation map of the collection device where the width of each bar is 1. Write a function that determines how much water the map is able to hold.
Given a string, return an array of all the permutations of that string. The permutations of the string should be the same length as the original string (i.e. use each letter in the string exactly once) but do not need to be actual words.
The array that is returned should only contain unique values and its elements should be in alphabetical order.
System Design questions tests the candidate ability to be able to create a system based on a user prompt. A user prompt is either a client telling you what they want or a team making an assumption of what a potential user might want in an idea. What makes this different from an OOP Design question is that this focuses less on the application components themselves and more of the flow of data and how we scale that data based on our understanding of the various trade offs as we modify our system.
User prompt: I want to be able to book movie theater seats online.
Design an API and a schema that may suit a movie ticket booking service.
Write a function that determines whether an input string has balanced brackets.
You are given an input string consisting of brackets—square [ ], round ( ), and curly { }. The input string can include other text. Write a function that returns either true if the brackets in the input string are balanced or false if they are not. Balanced means that any opening bracket of a particular type must also have a closing bracket of the same type.
An empty input string or a string without brackets is considered "balanced".
Write a function that takes in the heads of two Singly Linked Lists that are in sorted order. The function should merge the lists in place (i.e., it shouldn't create a brand new list) and return the head of the merged list in sorted order.
Each LinkedList node has an integer value as well as a next, pointing to the next node in the list or to null if it's the tail of the list.
The Fibonacci sequence is defined as follows: the first number of the sequence is 0, the second number is 1, and the nth number is the sum of the (n-1)th and (n-2)th numbers. Write a function that takes in an integer n and returns the nth Fibonacci number.
test cases
- nthFib(6) //5 ->(0,1,1,2,3,5)
You are given an array of integers and a target integer. Write a function that moves all instances of the target integer in the array to the end of the array. The order of the non-target integers in the array should be maintained.
Example
- Input: ([2, 1, 2, 2, 2, 3, 4, 2], 2)
- Output: [1, 3, 4, 2, 2, 2, 2, 2]
Most will go toward the naive solution quickly. If they do, that's awesome. Once they get a solution, talk about time and space complexity and make sure they realize why the naive solution is O(n) (linear) space complexity. Then ask if they can create a solution without using any extra space, or an O(1) (constant) space. Watch out for value swapping in the array because this may lead to scrambled non-target numbers in our result array.