We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
staticStringhackerrankInString(Strings){// Complete this functionStringnewString="";for(inti=0;i<s.length();i++){if(s.charAt(i)=='h'||s.charAt(i)=='a'||s.charAt(i)=='c'||s.charAt(i)=='k'||s.charAt(i)=='e'||s.charAt(i)=='r'||s.charAt(i)=='n'){newString+=s.charAt(i);}}StringanotherString="";Stringhackerrank="hackerrank";intj=0;for(inti=0;i<hackerrank.length();i++){for(;j<newString.length();){if(hackerrank.charAt(i)==newString.charAt(j)){anotherString+=newString.charAt(j);j=j+1;break;}j=j+1;}}if(anotherString.equals(hackerrank)){return"YES";}return"NO";}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
HackerRank in a String!
You are viewing a single comment's thread. Return to all comments →