This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
specification- | |
Given an N*N matrix. Print the elements of the matrix in anticlockwise order (see the sample for better understanding) | |
Sample Input | |
4 | |
1 2 3 4 | |
5 6 7 8 | |
9 10 11 12 | |
13 14 15 16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
specification- | |
Write a program to find the node at which the intersection of two singly linked lists begins. | |
For example, the following two linked lists: | |
Example- | |
Sample Input:- | |
1 - > 2 - > 3 - > 4 | |
↓ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#####******SOLUTION IN JAVA*******######## | |
specification:- | |
Given a number N, find all factors of N. | |
Example:- | |
N = 6 | |
factors = {1, 2, 3, 6} | |
public class Solution { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###***********java code*************###### | |
specification:- | |
Given a number N >= 0, find its representation in binary. | |
Example: | |
if N = 6, | |
binary form = 110 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
specification:- | |
Following code tries to figure out if a number is prime | |
public class Solution { | |
public int isPrime(int A) { | |
if(A==1){ | |
return 0; | |
} | |
else{ | |
int upperLimit = (int)(Math.sqrt(A)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
specification:- | |
Given a number N, find all prime numbers upto N ( N included ). | |
Example: | |
if N = 7, | |
all primes till 7 = {2, 3, 5, 7} | |
Make sure the returned array is sorted. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
specification:-Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. | |
Note: You can only move either down or right at any point in time. | |
grid = 1 3 1 | |
2 5 1 | |
4 2 1 | |
Input: grid = [[1,3,1],[1,5,1],[4,2,1]] | |
Output: 7 | |
Explanation: Because the path 1 → 3 → 1 → 1 → 1 minimizes the sum. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
specification:- You have an empty sequence, and you will be given N queries. Each query is one of these three types: | |
1 x -Push the element x into the stack. | |
2 -Delete the element present at the top of the stack. | |
3 -Print the maximum element in the stack. | |
sample input: | |
10 | |
1 97 | |
2 | |
1 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Problem Description:- | |
Given an array of integers, A of length N, find out the maximum sum sub-array of non negative numbers from A. | |
The sub-array should be contiguous i.e., a sub-array created by choosing the second and fourth element and | |
skipping the third element is invalid. | |
Maximum sub-array is defined in terms of the sum of the elements in the sub-array. | |
NOTE:- | |
1-If there is a tie, then compare with segment's length and return segment which has maximum length. | |
2-If there is still a tie, then return the segment with minimum starting index. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int main(){ | |
int a[10][10],b[10][10],mul[10][10],i,j,k,l,r,c; | |
cout<<"enter row size\n"; | |
cin>>r; | |
cout<<"row: "<<r<<endl; | |
cout<<"enter column size\n"; | |
cin>>c; | |
cout<<"column: "<<c<<endl; |