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 Ideone | |
{ | |
public static void main (String[] args) throws java.lang.Exception |
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
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.*; |
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
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 |
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
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". |
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
Discreption:- | |
original string:-Hello World | |
mask string:-Else | |
output:- Ho Word | |
class Ideone | |
{ | |
public static void main (String[] args) throws java.lang.Exception | |
{ |
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
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 { |
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
Example1- | |
Input: s = "Let's take LeetCode contest" | |
Output: "s'teL ekat edoCteeL tsetnoc" | |
example2- | |
Input: s = "God Ding" | |
Output: "doG gniD" | |
******************JAVA CODE**************************** |
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
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.*; |
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
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 |
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
Example-1 | |
input- | |
3 | |
4 | |
2 5 6 | |
4 6 8 10 | |
output- | |
6 |