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
/* package whatever; // don't place package name! */ | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
/* Name of the class has to be "Main" only if the class is public. */ | |
class Searchtarget | |
{ | |
public static boolean searchTarget(int[][] matrix,int target){ |
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 | |
class Solution { | |
public void sortColors(int[] nums) { | |
int zero=0,one=0,two=0; | |
for(int i:nums){ | |
if(i==0) zero++; | |
if(i==1) one++; | |
if(i==2) two++; | |
} |
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 a linked list A of length N and an integer B. | |
You need to find the value of the Bth node from the middle towards the beginning of the Linked List A. | |
If no such element exists, then return -1. | |
NOTE:-Position of middle node is: (N/2)+1, where N is the total number of nodes in the list. | |
Problem Constraints | |
1:-1 <= N <= 105 |
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 a Linked List A consisting of N nodes. | |
The Linked List is binary i.e data values in the linked list nodes consist of only 0's and 1's. | |
You need to sort the linked list and return the new linked list. | |
NOTE:-Try to do it in constant space. | |
Problem Constraints | |
1:- 1 <= N <= 105 |
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
### stack implementation using java language | |
/* package whatever; // don't place package name! */ | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
/* Name of the class has to be "Main" only if the class is public. */ | |
class Stack |
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
### queue operation in java | |
/* package whatever; // don't place package name! */ | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; |
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
The following code is supposed to rotate the array A by B positions. | |
Explanation | |
Input:-1 | |
A : [1 2 3 4 5 6] | |
B : 1 | |
Input:-2 | |
A:[ 14, 5, 14, 34, 42, 63, 17, 25, 39, 61, 97, 55, 33, 96, 62, 32, 98, 77, 35 ] | |
B:56 |
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 singly linked list, determine if its a palindrome. Return 1 or 0 denoting if its a palindrome or not, respectively. | |
Note:- | |
1-Expected solution is linear in time and constant in space. | |
Examples:- | |
List 1-->2-->1 is a palindrome. | |
List 1-->2-->3 is not a palindrome. | |
#################Code In Java################ |
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
Expalnation | |
input:- 1->2->2->3->3->3->4->null | |
output:-1->2->3->4->null | |
############################JAVA CODE###################################### | |
// Complete the removeDuplicates function below. | |
/* | |
* For your reference: |
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 matrix of m * n elements (m rows, n columns), return all elements of the matrix in spiral order. | |
Example:- | |
Input | |
[ | |
[ 1, 2, 3 ], | |
[ 4, 5, 6 ], | |
[ 7, 8, 9 ] | |
] |
OlderNewer