Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1
Solving one problem every day. Problem selection is based on the Daily Coding Problem newsletter
License
Shivam010/daily-coding-problem
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
People find their paths in the strangest of ways.
OnSeptember 03, 2020
, I found this websiteDaily Coding Problem, where you can subscribeto a newsletter and get one problem a day. I like the initiative: Solving one problem every day.
Also, after college, the daily job cycle began, which led to my breakup with competitive programming. But I wanted to startsolving problems again to keep it up, but could never begin.
So, I decided to subscribe the newsletter and to solve one problem every day.
Since then I have solved#67 problems
.You can find the problems and solutions in their directories:here.
Solutions are mainly inC++ and Golang, and some problems mayalso havePython solution too, depending on what is asked in question.
Checkout my blog post on my habit of solving a problem dailyhere
Want to join me? or Just need to stay upto date?
Start watching this repository or connect with me.
And if you want toreview my solutions or want toadd something, I am open for accepting PRs, code reviews.
Anything you feel that needs correction.
Next problem: #089
Missed problems: #068
• #069
• #070
• #071
• #072
• #073
• #074
• #075
• #076
• #077
• #078
• #079
• #080
• #081
• #082
• #083
• #084
• #085
• #086
• #087
• #088
Some of the worthy problems I have solved are listed here...
Date: September 12, 2020
This problem was asked by Apple.
Implement ajob scheduler which takes in a function f and an integer n, andcalls f after n milliseconds.
Solution(s):
•C++
•Golang
•Python
Date: October 24, 2020
This problem was asked by Google.
Implement anLRU (Least Recently Used) caching system. It should be able to beinitialized with a cache sizen
, and contain the following methods:
set(key, value)
: sets key to value. If there are already n items in the cacheand we are adding a new item, then it should also remove the least recently useditem.
get(key)
: gets the value at key. If no such key exists, return null. Eachoperation should run inO(1)
time.
Date: November 08, 2020
This problem was asked by Google.
Implement anLFU (Least Frequently Used) caching system. It should be able to beinitialized with a cache sizen
, and contain the following methods:
set(key, value)
: sets key to value. If there are already n items in the cacheand we are adding a new item, then it should also remove the least frequently useditem. 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. Eachoperation should run inO(1)
time.
Solution(s):
•Golang
Date: September 13, 2020
This problem was asked by Twitter.
Implement anautocomplete system. That is, given a query string s and a set ofall possible query strings, return all strings in the set that have s as aprefix.
For example, given the query stringde
and the set of strings[dog, deer, deal]
, return[deer, deal]
.
Hint: Try preprocessing the dictionary into a more efficient data structure tospeed up queries.
Date: October 31, 2020
This problem was asked by Google.
Implement a file syncing algorithm for two computers over a low-bandwidth network. What if we know the files in the twocomputers are mostly the same?
Solution(s):
•Golang
Date: September 17, 2020
This problem was asked by Facebook.
Given a stream of elements too large to store in memory, pick a random elementfrom the stream with uniform probability.
i.e.UniformSelection
Date: October 27, 2020
This problem was asked by Microsoft.
Implement a URL shortener with the following methods:
shorten(url)
, which shortens the url into a six-character alphanumericstring, such aszLg6wl
.restore(short)
, which expands the shortened string into the original url. Ifno such shortened string exists, return null.
Hint: What if we enter the same URL twice?
Date: September 26, 2020
This problem was asked by Google.
Implement locking in a binary tree. A binary tree node can be locked or unlockedonly if all of its descendants or ancestors are not locked.
Design a binary tree node class with the following methods:
is_locked
, which returns whether the node is locked.lock
, which attempts to lock the node. If it cannot be locked, then itshould return false. Otherwise, it should lock it and return true.unlock
, which unlocks the node. If it cannot be unlocked, then it shouldreturn false. Otherwise, it should unlock it and return true.
You may augment the node to add parent pointers or any other property you wouldlike. You may assume the class is used in a single-threaded program, so there isno need for actual locks or mutexes. Each method should run inO(h)
, whereh
is the height of the tree.
Solution(s):
•C++
Date: October 17, 2020
This problem was asked by Two Sigma.
Using a functionrand5()
that returns an integer from1 to 5 (inclusive)
with uniform probability, implement a functionrand7()
that returns an integerfrom1 to 7 (inclusive)
.
Date: September 24, 2020
This problem was asked by Microsoft.
Given a dictionary of words and a string made up of those words (no spaces),return the original sentence in a list. If there is more than one possiblereconstruction, return any of them. If there is no possible reconstruction, thenreturn null.
For example, given the set of words'quick', 'brown', 'the', 'fox'
, and thestring"thequickbrownfox"
, you should return['the', 'quick', 'brown', 'fox']
.
Given the set of words'bed', 'bath', 'bedbath', 'and', 'beyond'
, and the string"bedbathandbeyond"
, return either['bed', 'bath', 'and', 'beyond]
or['bedbath', 'and', 'beyond']
Solution(s):
•C++
Date: October 11, 2020
This problem was asked by Dropbox(System Design).
Conway's Game of Life takes place on an infinite two-dimensional board of squarecells. Each cell is either dead or alive, and at each tick, the following rulesapply:
Any live cell with less than two live neighbours dies.Any live cell with two or three live neighbours remains living.Any live cell with more than three live neighbours dies.Any dead cell with exactly three live neighbours becomes a live cell.A cell neighbours another cell if it is horizontally, vertically, or diagonallyadjacent.
Implement Conway's Game of Life. It should be able to be initialized with astarting list of live cell coordinates and the number of steps it should runfor. Once initialized, it should print out the board state at each step. Sinceit's an infinite board, print out only the relevant coordinates, i.e. from thetop-leftmost live cell to bottom-rightmost live cell.
You can represent a live cell with an asterisk(*)
and a dead cell with a dot(.)
.
Solution(s):
•C++
Date: October 28, 2020
This problem was asked by Google.
Given an undirected graph represented as an adjacency matrix and an integerk
,write a function to determine whether each vertex in the graph can be coloredsuch that no two adjacent vertices share the same color using at most k colors.
Solution(s):
•Golang
People find their paths in the strangest of ways. Let's find our own!
Let's connecthere.
About
Solving one problem every day. Problem selection is based on the Daily Coding Problem newsletter
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.