Rotate a Matrix List in Python
The challenge
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Note:
You have to rotate the image …
Read Article →320 articles about python development, tools, and best practices
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Note:
You have to rotate the image …
Read Article →Given two arrays, write a function to compute their intersection.
Example 1:
Example 2:
Note:
Given an array, rotate the array to the right by k steps, where k is non-negative.
Example 1:
Example 2:
Constraints:
1 <= …Python has a fantastic feature called slices. It allows you to work with a list, set or string by it’s index items.
E.g.:
string_sample = …
Read Article →
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input …
Read Article →Write a function:
def solution(A)
that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does …
Read Article →Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.
Find all the …
Read Article →Java has a built-in called HashMap. It allows you to store and very quickly retrieve key value pairs.
In Python, this is called a …
Read Article →In an N by N square grid, each cell is either empty (0) or blocked (1).
A clear path from top-left to bottom-right has length k if and …
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s …
Read Article →Say you have an array prices for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum …
Read Article →A self-dividing number is a number that is divisible by every digit it contains.
For example, 128 is a self-dividing number because 128 % …