Persistent Systems Interview Question for Software Engineer / Developers


Country: India
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
0
of 0 vote

String.replaceAll("replaceThis","WithThis");

- Anonymous March 29, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void replace_string(string src, const string key,const string replace){
   int k = src.find(key);
      while (k>0){
         src.replace(k, replace.length(), replace);
         k = src.find(key);
      }
}

- ms March 29, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

original = raw_input("Enter original string: ")
sub = raw_input("Enter substring: ")
replace = raw_input("Enter string to replace with: ")

index = original.find(sub,0,len(original))
if -1 != index :
    print original[:index] + replace + original[index+len(sub):]
else :
    print "Substring not found"

- manisht May 03, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

original = raw_input("Enter original string: ")
sub = raw_input("Enter substring: ")
replace = raw_input("Enter string to replace with: ")

index = original.find(sub,0,len(original))
if -1 != index :
    print original[:index] + replace + original[index+len(sub):]
else :
    print "Substring not found"

- Anonymous May 03, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

main()
{
char s1[100] = "sravani bad",s2[4]="good";
char *ptr,*temp;
ptr = s1;
while(ptr = strstr(ptr,s2))
{
strcpy(temp,ptr+strlen(s2));
strncpy(ptr,s2);
strcat(s1,temp);
}
}

- sravani July 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

main()
{
char s1[100] = "sravani bad",s2[4]="good";
char *ptr,*temp;
ptr = s1;
while(ptr = strstr(ptr,s2))
{
strcpy(temp,ptr+strlen(s2));
strncpy(ptr,s2);
strcat(s1,temp);
}
}

- sravani July 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static void replaceSubstring(String original,String substring, String replace){

if(original.contains(substring)){
String newStr = original.replaceFirst(substring, replace);
System.out.println(newStr);
}
else{
System.out.println("Substring not present");
}
}

- Anonymous July 10, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static void replaceSubstring(String original,String substring, String replace){
       
        if(original.contains(substring)){
            String newStr = original.replaceFirst(substring, replace);
            System.out.println(newStr); 
        }
        else{
            System.out.println("Substring not present");
        }
    }

- Anonymous July 10, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream>
#include<string>
using namespace std;
int main()
{
int index=0;
string src,substr,replace;
cin>>src>>substr>>replace;
index=src.find(substr,index);
while(index<=(src.length()-replace.length())){

src.replace(index,replace.length(),replace);
index=src.find(substr,index);

}
cout<<src;
return 0;
}

- Anonymous September 04, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class StringIndexOf {

public static void main(String args[]){

String s = args[0];
String substring = args[1];
String newString = args[2];
String output = "";

int length = substring.length();

int i =0;
int index = s.indexOf(substring);
if(index!=-1){

output = s.substring(0, index)+newString+s.substring(index+length, s.length());
}
System.out.println(s);
System.out.println(substring);
System.out.println(newString);

System.out.println(output);

}

}

- mrupanjana September 05, 2018 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More