Skip to content

Instantly share code, notes, and snippets.

View Ram-1234's full-sized avatar
🔍
looking for job change

Ramnayan yadav Ram-1234

🔍
looking for job change
View GitHub Profile
@Ram-1234
Ram-1234 / search 2D matrix
Last active January 4, 2021 11:31
serach target int value in matrix
/* 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){
// 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++;
}
@Ram-1234
Ram-1234 / LINKED LIST
Last active December 30, 2020 14:44
AMAZON LINKED LIST PROBLEM
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
@Ram-1234
Ram-1234 / sort binary linked list
Last active January 3, 2021 03:48
AMAZON LINKED LIST
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
@Ram-1234
Ram-1234 / stack operation code in java
Last active January 1, 2021 19:50
STACK OPERATION
### 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
@Ram-1234
Ram-1234 / queue operation in java
Created January 1, 2021 19:52
QUEUE OPERATION
### queue operation in java
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
@Ram-1234
Ram-1234 / Array Rotation Problem And solution java
Last active January 3, 2021 05:50
InterviewBit ARRAY_BUG
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
@Ram-1234
Ram-1234 / Polindrome List
Created January 3, 2021 06:37
InterviewBit LinkedList Polindrome Code In Java
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################
@Ram-1234
Ram-1234 / Duplicate-Value nodes removel in linked list java code
Created January 4, 2021 10:55
Delete duplicate-value nodes from a sorted linked list
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:
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 ]
]