All Questions
7
questions
1
vote
1
answer
166
views
Algorithm - How to pair blocks efficiently
lets say, we have two cubes of 3X3 with different heights in cell. Each cell value represents the height of that cell. For example in below block 1, cell (1,1) has height of 1, cell(1,2) has height of ...
1
vote
2
answers
134
views
Algorithm not showing right output
The Question was:
You are given a binary matrix (i.e. each element of matrix is either 0 or 1) of size n × n. You want to re-arrange 1's in such a way that they form a rectangular region. Note that ...
-1
votes
1
answer
433
views
Algorithm - Finding all maxima of k*k sets in n*n 2D Matrix
I have a N*N 2D matrix. I want to find all maximal value for each set k*k sub grid. What should be the efficient algorithm.For example,
N = 4, k = 2
0 1 3 1
5 2 1 4
2 3 0 7
Output: 3, 4, 5
3 came ...
0
votes
0
answers
219
views
How to find rectangular pattern coordinates in a 2d Matrix
I have an integer 2d matrix(6,5) as below:
I need to find the count of all the rectangular pattern that contains 3 dots and are not overlapping with their co-ordinates.
This was a question which came ...
1
vote
1
answer
815
views
Iterate over 2D Array outward to boundaries from arbitrary coordinates
I'm currently trying to create a function in Swift to traverse a 2-dimensional array of any number of rows or columns.
For example:
let array: [[Int]] = [
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
...
0
votes
2
answers
564
views
simple Inplace square matrix clockwise rotation in java - what is wrong with my code
class RotateMat {
static Integer[] swap(int x, int y) {
int a=x;
int b=y;
a=a^b;
b=a^b;
a=a^b;
return new Integer[]{a,b};
}
static int[][] rotate(int[][] arr) {
assert arr....
26
votes
5
answers
33k
views
Algorithm for finding nearest object on 2D grid
Say you have a 2D grid with each spot on the grid having x number of objects (with x >=0). I am having trouble thinking of a clean algorithm so that when a user specifies a coordinate, the algorithm ...