You are given an array representing a grid of a 2-dimensional map, along with the dimensions to correctly parse it. Array only consists of 1s and 0s, where 1 represents land and 0 represents seas.
A ...
Linear congruential generator is very basic algorithm to generate random numbers. Although it is a very fast algorithm, it may not generate very random variables. The formula of that generator is giv ...
Luhn is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers. Below is how this algorithm works:
From the rightmost digit, which is the check d ...
Given a non-negative number num find the square root of the number.
If the square root is not a integer return the whole part. (Ex sqrt(10) = 3)
Try to do it without using system libraries.
Please ...
You are given an array of non-negative integers where each element occurs exactly twice except one which occurs once.
Find the element occurring once.
Examples:
Input 1:
[1, 1, 2, 2, 3]
Output 1 ...
You have an enormous book collection and want to buy some shelves. You go to a store and they sell all kinds of shelves. The weird part is, some shelves are different in length but they all cost the ...
There are n plants in a garden. Each of these plants has been added with some amount of pesticide. After each day, if any plant has more pesticide than the plant on its left, being weaker than the le ...
Write an algorithm to compare two strings. Check if they are equal or not. If equal return True. Else False.
Example
If string1 is "codela" and string2 is "cdl" output return must be False.