NJNavnath Jadhavinnavnathjadhav.hashnode.dev·Mar 25, 2023 · 1 min readString Reverse in Java: Single Line SolutionProgram to Reverse a String Input: str="Navnath" Original String is: "Navnath" Output: revstr="htanvaN" Reverse String is: "htanvaN" Solution: Language Used: Java Approach 1: String Concatination import java.util.Scanner; public class reverse_stri...00
NJNavnath Jadhavinnavnathjadhav.hashnode.dev·Mar 22, 2023 · 3 min readSwap Two Numbers: In 5 Different WaysProgram to swap two numbers Input: Enter the value of X and Y num1=10 num2=20 Before swapping: 10 20 Output: num1=20 num2=10 After swapping: 20 10 Solution: Language Used: Java Approach 1: swap two numbers using the third variable import java...00
NJNavnath Jadhavinnavnathjadhav.hashnode.dev·Feb 5, 2023 · 2 min readWord CountProblem Description Given a string A. The string contains some words separated by spaces.Return the number of words in the given string. Problem Constraints 1 <= |A| <= 105Ai = { lowercase English letters or spaces} Input Format The first and only ar...00
NJNavnath Jadhavinnavnathjadhav.hashnode.dev·Feb 4, 2023 · 4 min readPermutation in StringGiven two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1's permutations are the substring of s2. Example 1: Input: s1 = "ab", s2 = "eidbaooo" Output: true Explanation: s...00
NJNavnath Jadhavinnavnathjadhav.hashnode.dev·Feb 1, 2023 · 1 min readGreatest Common Divisor of StringsProblem: For two strings s and t, we say "t divides s" if and only if s = t + ... + t (i.e., t is concatenated with itself one or more times). Given two strings str1 and str2, return the largest string x such that x divides both str1 and str2. Exampl...00