Bloomberg Interview Question

design an algorithm to decide if a string str1 contains str2

Interview Answers

Anonymous

Mar 23, 2017

use for loop

Anonymous

Aug 16, 2017

//design an algorithm to decide if a string str1 contains str2 bool isSubstring(string str1, string str2) { char firstL = str2[0]; for(int i = 0; i = str1.size() || str1[i] != str2[j]) { valid = false; } } if(valid) { return true; } else { i--; } } } return false; }