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
/* 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 Ideone
{
public static void main (String[] args) throws java.lang.Exception
@Ram-1234
Ram-1234 / Array Indicies
Created April 19, 2021 14:30
Given an array of integers, return indices of the two numbers such that they add up to a specific target
Descreption-Write a program for the below. Given an array of integers,
return indices of the two numbers such that they add up to a specific target.
Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9,return [0, 1].
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
@Ram-1234
Ram-1234 / Swap Last Name
Created April 19, 2021 14:32
Write Java program to Swap the First name and Last name
Description-Write Java program to Swap the First name and Last name Ex :-
Input : "Mary Elizabeth Smith " Output : "Smith Elizabeth Mary "
class Replacename
{
public static void main (String[] args) throws java.lang.Exception
@Ram-1234
Ram-1234 / Destination City
Created April 21, 2021 02:56
You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outgoing to another city.
Discription-
Input: paths = [["London","New York"],["New York","Lima"],["Lima","Sao Paulo"]]
Output: "Sao Paulo"
Explanation: Starting at "London" city you will reach "Sao Paulo" city which is the destination city. Your trip consist of: "London" -> "New York" -> "Lima" -> "Sao Paulo".
Input: paths = [["B","C"],["D","B"],["C","A"]]
Output: "A"
Explanation: All possible trips are:
"D" -> "B" -> "C" -> "A".
"B" -> "C" -> "A".
@Ram-1234
Ram-1234 / Remove Redundant Character From Original String
Last active April 30, 2021 03:28
given two string original string and mask string remove char from original array if char present in mask string
Discreption:-
original string:-Hello World
mask string:-Else
output:- Ho Word
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
@Ram-1234
Ram-1234 / Longest Common Prefix LeetCode
Created April 25, 2021 16:43
Write a function to find the longest common prefix string amongst an array of strings.
Input: strs = ["flower","flow","flight"]
Output: "fl"
Input: strs = ["dog","racecar","car"]
Output: ""
Explanation: There is no common prefix among the input strings.
**********java code******************
class Solution {
@Ram-1234
Ram-1234 / Reverse Words in a String III Solution In Java
Created April 26, 2021 08:25
Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Example1-
Input: s = "Let's take LeetCode contest"
Output: "s'teL ekat edoCteeL tsetnoc"
example2-
Input: s = "God Ding"
Output: "doG gniD"
******************JAVA CODE****************************
character frequency in string java code using double loop method.
********************JAVA CODE**********************
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
@Ram-1234
Ram-1234 / Reverse Words in a String
Created April 29, 2021 17:28
Reverse a string and remove extra spaces between string
Example-1
Input: s = "the sky is blue"
Output: "blue is sky the"
Example-2
Input: s = " hello world "
Output: "world hello"
Explanation: Your reversed string should not contain leading or trailing spaces.
Example-3
@Ram-1234
Ram-1234 / common elements
Created April 30, 2021 12:32
Given two sorted arrays of integers, print the common elements between two arrays in a single loop
Example-1
input-
3
4
2 5 6
4 6 8 10
output-
6