Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,197,810 members, 7,965,983 topics. Date: Friday, 04 October 2024 at 06:37 AM

Deradees's Posts

Nairaland Forum / Deradees's Profile / Deradees's Posts

(1) (2) (of 2 pages)

Travel / Re: Self-driving Buses Where You Pay By Scanning Your Palm,Are Now In China by deradees: 11:32am On Jun 17, 2019
freemanbubble:


That is difficult mehnnnnn

If I (an itibolibo) can learn it, anybody can learn It as well. Just be committed
Travel / Re: Self-driving Buses Where You Pay By Scanning Your Palm,Are Now In China by deradees: 11:29am On Jun 17, 2019
freemanbubble:
Mehhnnnnn

See programming

Na im we still dey use smart card for obaseki buses

And the worse part of it uniben go still dey subject us to old programming language like Fortran and Pascal when nor get use in future

Nigeria is cursed

You can learn programming on your own
Programming / Re: Daily Coding Problem by deradees: 2:10am On Jun 15, 2019
Given a 2-D matrix representing an image, a location of a pixel in the screen and a color C, replace the color of the given pixel and all adjacent same colored pixels with C.

For example, given the following matrix, and location pixel of (2, 2), and 'G' for green:

B B W
W W W
W W W
B B B
Becomes

B B G
G G G
G G G
B B B
Programming / Re: Daily Coding Problem by deradees: 2:08am On Jun 15, 2019
This problem was asked by Triplebyte.

You are given n numbers as well as n probabilities that sum up to 1. Write a function to generate one of the numbers with its corresponding probability.

For example, given the numbers [1, 2, 3, 4] and probabilities [0.1, 0.5, 0.2, 0.2], your function should return 1 10% of the time, 2 50% of the time, and 3 and 4 20% of the time.

You can generate random numbers between 0 and 1 uniformly.
Programming / Re: Daily Coding Problem by deradees: 2:07am On Jun 15, 2019
This problem was asked by Amazon.

Implement a stack API using only a heap. A stack implements the following methods:

push(item), which adds an element to the stack
pop(), which removes and returns the most recently added element (or throws an error if there is nothing on the stack)
Recall that a heap has the following operations:

push(item), which adds a new key to the heap
pop(), which removes and returns the max value of the heap

1 Like

Programming / Re: Daily Coding Problem by deradees: 2:06am On Jun 15, 2019
This problem was asked by Facebook.

Given a positive integer n, find the smallest number of squared integers which sum to n.

For example, given n = 13, return 2 since 13 = 32 + 22 = 9 + 4.

Given n = 27, return 3 since 27 = 32 + 32 + 32 = 9 + 9 + 9.
Programming / Re: Daily Coding Problem by deradees: 2:04am On Jun 15, 2019
This problem was asked by Amazon.

Given a string, determine whether any permutation of it is a palindrome.

For example, carrace should return true, since it can be rearranged to form racecar, which is a palindrome. daily should return false, since there's no rearrangement that can form a palindrome.
Programming / Re: Daily Coding Problem by deradees: 2:02am On Jun 15, 2019
This problem was asked by Slack.

You are given an N by M matrix of 0s and 1s. Starting from the top left corner, how many ways are there to reach the bottom right corner?

You can only move right and down. 0 represents an empty space while 1 represents a wall you cannot walk through.

For example, given the following matrix:

[[0, 0, 1],
[0, 0, 1],
[1, 0, 0]]
Return two, as there are only two ways to get to the bottom right:

Right, down, down, right
Down, right, down, right
The top left corner and bottom right corner will always be 0.
Programming / Re: Daily Coding Problem by deradees: 2:01am On Jun 15, 2019
Given a 32-bit integer, return the number with its bits reversed.

For example, given the binary number 1111 0000 1111 0000 1111 0000 1111 0000, return 0000 1111 0000 1111 0000 1111 0000 1111.
Programming / Re: Daily Coding Problem by deradees: 1:59am On Jun 15, 2019
This problem was asked by Square.

Given a list of words, return the shortest unique prefix of each word. For example, given the list:

dog
cat
apple
apricot
fish
Return the list:

d
c
app
apr
f
Programming / Re: Daily Coding Problem by deradees: 1:58am On Jun 15, 2019
This problem was asked by Jane Street.

Given an arithmetic expression in Reverse Polish Notation, write a program to evaluate it.

The expression is given as a list of numbers and operands. For example: [5, 3, '+'] should return 5 + 3 = 8.

For example, [15, 7, 1, 1, '+', '-', '/', 3, '*', 2, 1, 1, '+', '+', '-'] should return 5, since it is equivalent to ((15 / (7 - (1 + 1))) * 3) - (2 + (1 + 1)) = 5.

You can assume the given expression is always valid.
Programming / Re: Daily Coding Problem by deradees: 1:56am On Jun 15, 2019
This problem was asked by Google.

You are given an array of length n + 1 whose elements belong to the set {1, 2, ..., n}. By the pigeonhole principle, there must be a duplicate. Find it in linear time and space.
Programming / Re: Daily Coding Problem by deradees: 1:55am On Jun 15, 2019
This problem was asked by Google.

Given an array of integers, return a new array where each element in the new array is the number of smaller elements to the right of that element in the original input array.

For example, given the array [3, 4, 9, 6, 1], return [1, 1, 2, 1, 0], since:

There is 1 smaller element to the right of 3
There is 1 smaller element to the right of 4
There are 2 smaller elements to the right of 9
There is 1 smaller element to the right of 6
There are no smaller elements to the right of 1
TV/Movies / Re: What Movie Are You Watching Now? by deradees: 12:20am On Jun 12, 2019
Can you please help me with the link to download the movie Concussions. It is a 2015 movie featuring Will Smith as Dr Omalu. Thanks
Celebrities / Re: 23-yr-old Nigerian Artiste, Armani, Proposes To His 47-yr-old Spanish Girlfriend by deradees: 4:05am On May 31, 2019
kennygee:
To a woman more than double his age?

His mother's reaction will be priceless.

Age is just a number. Love conquers all
Programming / Re: Help With This Book If You Have It. by deradees: 5:23pm On May 24, 2019
Please, I also need the book and other books on android. My e-mail address is chideraamadi66@gmail.com
Programming / Re: Daily Coding Problem by deradees: 2:53am On May 23, 2019
This problem was asked by Google.

Given the head of a singly linked list, reverse it in-place.
Programming / Re: Daily Coding Problem by deradees: 2:51am On May 23, 2019
This problem was asked by Lyft.

Given a list of integers and a number K, return which contiguous elements of the list sum to K.

For example, if the list is [1, 2, 3, 4, 5] and K is 9, then it should return [2, 3, 4], since 2 + 3 + 4 = 9.
Programming / Re: Daily Coding Problem by deradees: 2:49am On May 23, 2019
This question was asked by Google.

Given an integer n and a list of integers l, write a function that randomly generates a number from 0 to n-1 that isn't in l (uniform).
Programming / Re: Daily Coding Problem by deradees: 2:48am On May 23, 2019
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
Programming / Re: Daily Coding Problem by deradees: 2:47am On May 23, 2019
This problem was recently asked by Google.

Given a list of numbers and a number k, return whether any two numbers from the list add up to k.

For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.

Bonus: Can you do this in one pass?
Programming / Re: Daily Coding Problem by deradees: 2:46am On May 23, 2019
This problem was asked by Google.

Determine whether a doubly linked list is a palindrome. What if it’s singly linked?

For example, 1 -> 4 -> 3 -> 4 -> 1 returns True while 1 -> 4 returns False.
Programming / Re: Daily Coding Problem by deradees: 2:45am On May 23, 2019
You are in an infinite 2D grid where you can move in any of the 8 directions:

(x,y) to
(x+1, y),
(x - 1, y),
(x, y+1),
(x, y-1),
(x-1, y-1),
(x+1,y+1),
(x-1,y+1),
(x+1,y-1)
You are given a sequence of points and the order in which you need to cover the points. Give the minimum number of steps in which you can achieve it. You start from the first point.

Example:

Input: [(0, 0), (1, 1), (1, 2)]
Output: 2
It takes 1 step to move from (0, 0) to (1, 1). It takes one more step to move from (1, 1) to (1, 2).
Programming / Re: Daily Coding Problem by deradees: 2:44am On May 23, 2019
This problem was asked by Palantir.

Given a number represented by a list of digits, find the next greater permutation of a number, in terms of lexicographic ordering. If there is not greater permutation possible, return the permutation with the lowest value/ordering.

For example, the list [1,2,3] should return [1,3,2]. The list [1,3,2] should return [2,1,3]. The list [3,2,1] should return [1,2,3].

Can you perform the operation without allocating extra memory (disregarding the input memory)?
Programming / Re: Daily Coding Problem by deradees: 2:43am On May 23, 2019
This problem was asked by Amazon.

Run-length encoding is a fast and simple method of encoding strings. The basic idea is to represent repeated successive characters as a single count and character. For example, the string "AAAABBBCCDAA" would be encoded as "4A3B2C1D2A".

Implement run-length encoding and decoding. You can assume the string to be encoded have no digits and consists solely of alphabetic characters. You can assume the string to be decoded is valid.
Programming / Re: Daily Coding Problem by deradees: 2:42am On May 23, 2019
This problem was asked by Dropbox.

What does the below code snippet print out? How can we fix the anonymous functions to behave as we'd expect?

functions = []
for i in range(10):
functions.append(lambda : i)

for f in functions:
print(f())
Programming / Re: Daily Coding Problem by deradees: 2:41am On May 23, 2019
This problem was asked by Facebook.

Given a string and a set of delimiters, reverse the words in the string while maintaining the relative order of the delimiters. For example, given "hello/world:here", return "here/world:hello"

Follow-up: Does your solution work for the following cases: "hello/world:here/", "hello//world:here"
Programming / Re: Daily Coding Problem by deradees: 2:39am On May 23, 2019
This problem was asked by Facebook.

Given an array of numbers representing the stock prices of a company in chronological order and an integer k, return the maximum profit you can make from k buys and sells. You must buy the stock before you can sell it, and you must sell the stock before you can buy it again.

For example, given k = 2 and the array [5, 2, 4, 0, 1], you should return 3.
Programming / Re: Daily Coding Problem by deradees: 2:38am On May 23, 2019
This problem was asked by Square.

Given a string and a set of characters, return the shortest substring containing all the characters in the set.

For example, given the string "figehaeci" and the set of characters {a, e, i}, you should return "aeci".

If there is no substring containing all the characters in the set, return null.
Programming / Re: Daily Coding Problem by deradees: 2:37am On May 23, 2019
This problem was asked by Jane Street.

Generate a finite, but an arbitrarily large binary tree quickly in O(1).

That is, generate() should return a tree whose size is unbounded but finite.
Programming / Re: Daily Coding Problem by deradees: 2:36am On May 23, 2019
This problem was asked by Google.

Given a sorted list of integers, square the elements and give the output in sorted order.

For example, given [-9, -2, 0, 2, 3], return [0, 4, 4, 9, 81].

(1) (2) (of 2 pages)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 33
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.