 Daily coding problems | Sololearn: Learn to code for FREE!

+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.

+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

+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.

+7

Thank you for this thread ❤️ My try in C to #1.1: https://code.sololearn.com/cx07ULTKLAy4/?ref=app

+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. 😊😁❤

+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.

+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

+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.

+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.

+5

+4

I'm loving these problems... I'll try some out ASAP

+4

please give an example of problem 3.1 or elaborate it it simple terms.. ....thanks

+3

Oneliner https://code.sololearn.com/cLTPP9l1DTD6/?ref=app

+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

+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

+1

Daily Coding Problem..#2.2 https://code.sololearn.com/c34xr6NXZ1qH/?ref=app

+1

#3.2 https://code.sololearn.com/cKyM7opmFUd0/?ref=app

0

i was gonna cheese this with Math.Pow but i decided against it https://code.sololearn.com/cI0eY6yLVNEV/?ref=app

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.