Pergunta de entrevista da empresa Amazon

Write a function to find a substring in a string. Test your code, write the test cases.

Respostas da entrevista

Sigiloso

3 de abr. de 2017

public static void main(String[] args) { String str = "HelloWorld Vivek"; String ptr = ""; for ( int i = 0 ; i < str.length(); i++ ) { for ( int j = i+1; j <= str.length() ; j++) { ptr = str.substring(i,j); System.out.println(ptr); } } }

Sigiloso

13 de mai. de 2017

def substrng(str1,str2): if str2 in str1: print ("substring found") else: print ("No substring found")

Sigiloso

22 de mar. de 2019

static boolean findSubString(String str) { String abc = "SaurabhThawali"; for(int i =0 ; i < str.length(); i++) { if( ! abc.contains(str)) { System.out.println("Not Found "); return false; } } System.out.println(" Found "); return true; }

Sigiloso

23 de jun. de 2017

private static void substringsOfAString(String str){ for(int i=0; i<=str.length()-1; i++){ for(int j=i+1; j<=str.length();j++){ System.out.println(str.substring(i, j) ); } } }