+ 16

Daily coding problems

Apart from my regular study, I decided to work out two 'quality' questions, daily, which were asked in the interviews by companies. I'll post the questions daily so that I can get a solution when i'm stuck and I can learn different approaches to a problem. Hope this thread will help at least half a dozen of users.

7th Mar 2018, 4:26 PM
CSK
19 Respostas
+ 10
DAILY CODING PROBLEM #3.2 This problem was asked by Amazon. Given a N by M matrix of numbers, print out the matrix in a clockwise spiral. For example, given the following matrix: [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]] You should print out the following: 1 2 3 4 5 10 15 20 19 18 17 16 11 6 7 8 9 14 13 12
11th Mar 2018, 2:30 PM
CSK
+ 8
DAILY CODING PROBLEM #1.2 This problem was asked by Microsoft. Given a 2D matrix of characters and a target word, write a function that returns whether the word can be found in the matrix by going left-to-right, or up-to-down. For example, given the following matrix: [['F', 'A', 'C', 'I'], ['O', 'B', 'Q', 'P'], ['A', 'N', 'O', 'B'], ['M', 'A', 'S', 'S']] and the target word 'FOAM', you should return true, since it's the leftmost column. Similarly, given the target word 'MASS', you should return true, since it's the last row.
7th Mar 2018, 4:36 PM
CSK
+ 7
Thank you for this thread ❤️ My try in C to #1.1: https://code.sololearn.com/cx07ULTKLAy4/?ref=app
9th Mar 2018, 10:18 PM
MARTA
MARTA - avatar
+ 7
I couldn't post the problems daily due to time constraints. I would like to create a thread and i'll add the collection of all the coding problems over there. So, you can take up any number of problems per day and solve them. You can add your own coding problems there too. Thanks for participation. 😊😁❤
17th Mar 2018, 12:24 PM
CSK
+ 6
DAILY CODING PROBLEM #1.1 This problem was asked by Facebook. There is an N by M matrix of zeroes. Given N and M, write a function to count the number of ways of starting at the top-left corner and getting to the bottom-right corner. You can only move right or down. For example, given a 2 by 2 matrix, you should return 2, since there are two ways to get to the bottom-right: -Right, then down -Down, then right Given a 5 by 5 matrix, there are 70 ways to get to the bottom-right.
7th Mar 2018, 4:28 PM
CSK
+ 6
DAILY CODING PROBLEM #2.1 This problem was asked by Google. A knight's tour is a sequence of moves by a knight on a chessboard such that all squares are visited once. Given N, write a function to return the number of knight's tours on an N by N chessboard
8th Mar 2018, 3:59 PM
CSK
+ 6
DAILY CODING PROBLEM #2.2 This problem was asked by Google. Implement integer exponentiation. That is, implement the pow(x, y) function, where x and y are integers and returns x^y. Do this faster than the naive method of repeated multiplication. For example, pow(2, 10) should return 1024.
8th Mar 2018, 4:00 PM
CSK
+ 6
DAILY CODING PROBLEM #3.1 This problem was asked by Google. Implement an LFU (Least Frequently Used) cache. It should be able to be initialized with a cache size n, and contain the following methods: set(key, value): sets key to value. If there are already n items in the cache and we are adding a new item, then it should also remove the least frequently used item. If there is a tie, then the least recently used key should be removed.get(key): gets the value at key. If no such key exists, return null. Each operation should run in O(1) time.
11th Mar 2018, 2:27 PM
CSK
+ 5
@El_ahmady, waiting for your solutions brother ❤
9th Mar 2018, 8:00 PM
CSK
+ 4
I'm loving these problems... I'll try some out ASAP
9th Mar 2018, 7:59 PM
El_ahmady
El_ahmady - avatar
+ 4
please give an example of problem 3.1 or elaborate it it simple terms.. ....thanks
11th Mar 2018, 2:46 PM
sayan chandra
sayan chandra - avatar
11th Mar 2018, 4:37 PM
VcC
VcC - avatar
+ 2
first ans... ##added...any start point..any end point ##added...u can put forbidden points...(those if in a path; the path is cancelled) https://code.sololearn.com/c7pui8yMCwUR/?ref=app
7th Mar 2018, 7:10 PM
sayan chandra
sayan chandra - avatar
+ 2
Daily coding pblm 3.2 see u asked to give a matrix...and write it in clockwise order... i had a code with this logic... the diff is u input the size as a number and the code prints spiral clockwise matrix.. if u give input as 3... output will be 1 2 3 8 9 4 7 6 5 ## logic remains same...so posting this as a ans/)) https://code.sololearn.com/cNCzt3qU6XTs/?ref=app
11th Mar 2018, 2:44 PM
sayan chandra
sayan chandra - avatar
8th Mar 2018, 4:19 PM
sayan chandra
sayan chandra - avatar
12th Mar 2018, 8:48 AM
Abhimanyu Gupta
Abhimanyu Gupta - avatar
0
i was gonna cheese this with Math.Pow but i decided against it https://code.sololearn.com/cI0eY6yLVNEV/?ref=app
9th Mar 2018, 1:26 PM
hinanawi
hinanawi - avatar
0
Liked of the questions, but the problem is that the questions are very difficult that's the matter of nobody reply. But liked the initiative to disclose the questions.
9th Mar 2018, 10:18 PM
Diogo
Diogo - avatar
0
..
10th Apr 2018, 10:54 PM
Amir Galanty
Amir Galanty - avatar