tag:blogger.com,1999:blog-694855878384792308.post2546912085251947633..comments2024-03-21T06:26:49.387-07:00Comments on Java67: Top 21 String Programming and Coding Interview Questions With Solutionsjavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-694855878384792308.post-41738986411247967402023-05-18T19:46:18.226-07:002023-05-18T19:46:18.226-07:00Hi guys,
here is the solution for question number ...Hi guys,<br />here is the solution for question number 4 "How to remove characters from the first String which are present in the second String?"<br /> public static void main(String[] args) {<br /> String st1 = "india is great";<br /> String st2 = "in";<br /> List secondStringList = st2.chars().mapToObj(c -> (char) c).collect(Collectors.toList());<br /> String outputString = st1.chars().mapToObj(c -> (char) c).filter(c -> !secondStringList.contains(c)).map(ch -> new String(String.valueOf(ch)))<br /> .collect(Collectors.joining(""));<br /> System.out.println("outputString : " + outputString);<br /> }<br />Sohelhttps://www.blogger.com/profile/08198283656501981563noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-55516991993678373062022-11-05T12:16:07.405-07:002022-11-05T12:16:07.405-07:00val str = "aabbbbaa"
var l = str.length
...val str = "aabbbbaa"<br />var l = str.length<br />var s = ""<br />while (l>0){<br /> s = s + str.get(l-1)<br /> l--<br />}<br />if(s.equals(str)) {<br /> println("palindrome string : " + s)<br />}else{<br /> println("No palindrome string : " + s)<br />}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-16785552879556698702022-09-01T01:20:56.233-07:002022-09-01T01:20:56.233-07:00boolean b=true;boolean b=true;legnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-1450501183927315482022-02-03T23:55:03.103-08:002022-02-03T23:55:03.103-08:0019)function isPalindrome(str) {
let emptyArr = [...19)function isPalindrome(str) {<br /> let emptyArr = [];<br /><br /> for (let i = 0; i < str.length; i++) {<br /> let x = str[i];<br /><br /> if (x == "(" || x == "[" || x == "{") {<br /> emptyArr.push(x);<br /> continue;<br /> }<br /><br /> if (emptyArr.length == 0) return false;<br /><br /> let y;<br /> switch (x) {<br /> case ")":<br /> y = emptyArr.pop();<br /> if (y == "{" || y == "[") return false;<br /> break;<br /><br /> case "}":<br /> y = emptyArr.pop();<br /> if (y == "(" || y == "[") return false;<br /> break;<br /><br /> case "]":<br /> y = emptyArr.pop();<br /> if (y == "(" || y == "{") return false;<br /> break;<br /> }<br /> }<br /><br /> return emptyArr.length == 0;<br />}<br /><br />if (isPalindrome("{}")) console.log(true);<br />else console.log(false);Anonymoushttps://www.blogger.com/profile/08986837762210195203noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-36502730888817210652021-12-04T07:50:27.383-08:002021-12-04T07:50:27.383-08:00public static void NoOfOcuu(String s){
int...public static void NoOfOcuu(String s){<br /> int c=0,c2=0;<br /> ArrayListn=new ArrayList<>();<br /> char c1='0';<br /> for(int i=0;i=i)&&(c2==0)) {<br /> if (s.charAt(i) == s.charAt(j)) {<br /> c++;<br /> }<br /> }<br /> }<br /> if(c>1){<br /> n.add(s.charAt(i));<br /> }<br /> if(c>0) {<br /> System.out.println("the vale:" + s.charAt(i) + " - " + c);<br /> }<br /> }<br /> }Divyashreehttps://www.blogger.com/profile/08861256857542115815noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-57010674071543366172021-12-04T07:25:48.682-08:002021-12-04T07:25:48.682-08:00public class OccObj {
public static void main(...public class OccObj {<br /> public static void main(String[] args){<br /> Scanner input=new Scanner(System.in);<br /> String s= input.next();<br /> NoOfOcuu(s);<br /> }<br /> public static void NoOfOcuu(String s){<br /> int c=0,c2=0;<br /> ArrayListn=new ArrayList<>();<br /> char c1='0';<br /> for(int i=0;i=i)&&(c2==0)) {<br /> if (s.charAt(i) == s.charAt(j)) {<br /> c++;<br /> }<br /> }<br /> }<br /> if(c>1){<br /> n.add(s.charAt(i));<br /> }<br /> if(c>0) {<br /> System.out.println("the vale:" + s.charAt(i) + " - " + c);<br /> }<br /> }<br /> }<br />}<br />Divyashreehttps://www.blogger.com/profile/08861256857542115815noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-91710633645490692052021-10-18T21:47:51.453-07:002021-10-18T21:47:51.453-07:00Yes, you are right but once you know how to count ...Yes, you are right but once you know how to count character then the other one becomes simple because you just need to return the character with maximum count<br />javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-21703561318325851452021-10-18T21:47:25.961-07:002021-10-18T21:47:25.961-07:00That's correct but once you know how to count ...That's correct but once you know how to count character then the other one becomes simple because you just need to return the character with maximum countjavin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-83618933721236093542020-03-25T18:26:03.782-07:002020-03-25T18:26:03.782-07:00yes both are different
example
1)How to find t...yes both are different <br /><br />example <br /><br />1)How to find the maximum occurring character in given String?"<br /><br />Malyalaum - a-3 (a is the maximum occurring character in given string)<br /><br />2) How to Count Occurrences of a Character in String<br />Malyalaum<br />m-2<br />a-3<br />y-1<br />u-1<br /><br />thank you,<br />riahttps://www.blogger.com/profile/17902680536976763647noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-76601223877565949932020-01-13T19:15:46.672-08:002020-01-13T19:15:46.672-08:00Hi guys,
here the first question is "How to f...Hi guys,<br />here the first question is "How to find the maximum occurring character in given String?"<br /><br />but the solution link is for "How to Count Occurrences of a Character in String"<br /><br />Both are different, Please confirm...Anonymousnoreply@blogger.com