14-03-2023
14-03-2023
14-03-2023
write a program to read an array of elements & rotate array of k elements from
the array
for other boundary conditions print -1.
for example:
input:
5
3
1 2 3 4 5
Output:
3 4 5 1 2
first line reads the size of the array, followed by k elements to rotate ,then
followed by elements
so given elements 1 2 3 4 5 we need to rotate three times
elements in first rotation 5 1 2 3 4
elements in second rotation 4 5 1 2 3
elements in third rotation 3 4 5 1 2 .
so output will be 3 4 5 1 2
*/
case=1
input=5
5
1 2 3 4 5
output=1 2 3 4 5
case=2
input=5
6
1 2 3 4 5
output=5 1 2 3 4
case=3
input=5
-2
1 2 3 4 5
output=-1
import java.util.*;
/*
*
You have a list of words and a pattern, and you want to know which words in words
matches the pattern.
A word matches the pattern if there exists a permutation of letters p so that after
replacing
every letter x in the pattern with p(x), we get the desired word.
Return a list of the words in words that match the given pattern.
Note:
1 <= words.length <= 50
1 <= pattern.length = words[i].length <= 20
Sample Input:
abc deq mee aqq dkd ccc
abb
Sample Output:
aqq mee
Explanation:
"mee" matches the pattern because there is a permutation {a -> m, b -> e, ...}.
"ccc" does not match the pattern because {a -> c, b -> c, ...} is not a
permutation,
since a and b map to the same letter.
*
*/
case=1
input=pqrs psps lmno lmlm
abab
output=lmlm psps
case=2
input=bpqrs ppsps almno lmlm nnono cckck
jjljl
output=cckck nnono ppsps
case=3
input=ssske wxyz abcd iikl jklm
zyxw
output=abcd jklm wxyz
case=4
input=ssske wxyz abcd iikl jklm klmnn opqrs
zyxww
output=klmnn
import java.util.*;
return true;
}
}
}
Given a binary matrix M of size n X m. Find the maximum area of a rectangle formed
only of 1s in the given matrix.
Example 1:
Input:
n = 4, m = 4
M[][] = {{0 1 1 0},
{1 1 1 1},
{1 1 1 1},
{1 1 0 0}}
Output: 8
Explanation: For the above test case the
matrix will look like
0 1 1 0
1 1 1 1
1 1 1 1
1 1 0 0
the max size rectangle is
1 1 1 1
1 1 1 1
and area is 4 *2 = 8.
Your Task:
Your task is to complete the function maxArea which returns the maximum size
rectangle area in a binary-sub-matrix with all 1’s. The function takes 3 arguments
the first argument is the Matrix M[ ] [ ] and the next two are two integers n and m
which denotes the size of the matrix M.