nauld
BAN USER- 0of 0 votes
AnswersCombination of these two leetcode question.
- nauld in United States
Given a digital strings, find all the sentence it can represent.
Digital to letter mapping is same as telephone keypad.
Separating the letters according to a dictionary to form sentences.
https://leetcode.com/problems/letter-combinations-of-a-phone-number/
https://leetcode.com/problems/word-break-ii/| Report Duplicate | Flag | PURGE
Google SDE-3 Algorithm - 0of 2 votes
Answers// TokenBucket
- nauld in United States
// Goal: regulate a resource of some kind (1 token = 1 unit of a resource)
//
// init(start_tokens, max_tokens, fill_rate)
// get_tokens(int tokens)
// - block until those tokens are available in the token bucket
// - if number of tokens in the bucket is less than requested number of tokens, wait
// put_tokens(int tokens)
// - block until there is space in the token bucket for those tokens.
// fill_rate: x tokens per sec are added to the token bucket
Thread communication methods allowed are listed below. No thread safe collections are allowed.
// Lock()
// - lock()
// - unlock()
// ConditionVariable()
// - wait(lock, max_time_to_wait_in_secs)
// - releases lock before sleep and then reacquires lock upon waking
// - notify(): This wakes up 1 waiter on this condition variable
// - notifyAll(): Wakes up all waiters on this condition variable| Report Duplicate | Flag | PURGE
Google SDE-3 Algorithm