Note that there are some explanatory texts on larger screens.

plurals
  1. POfind smallest sub segment
    primarykey
    data
    text
    <p>I have given a Long Sentence and some words(to be searched in the sentence), i have to find the smallest part of the sentence which contains all the words to be Searched in that Sentence and print that part.</p> <p>I have tried it, 1. First get all locations(indexes) of all words from the given sentence. 2. then try to find smallest part from these indexes of words.</p> <p>But i am having problem implementing 2nd part . So i want some advice for it or if you suggest any other algorithm which can make it fast.</p> <pre><code>import java.util.*; import java.io.*; public class ShotestSubSegment2 { static SearchStr[] search; static String copystr; public static void main(String s[]) { try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = in.readLine(); copystr = str.substring(0).toLowerCase(); int k = Integer.parseInt(in.readLine()); search = new SearchStr[k]; for(int i=0;i&lt;k;i++) { search[i] = new SearchStr(in.readLine().toLowerCase()); getIndicesOf(search[i]); if(search[i].noOfElements()==0) { System.out.println("No Segments Found"); return; } } searchSmallestPart();//Dont getting Idea Of this } catch(Exception x){} } public static void getIndicesOf(SearchStr searchS) { String searchStr = searchS.getName(); int startIndex = 0, searchStrLen=0; int index; searchStr = searchStr.toLowerCase(); searchStrLen = searchStr.length(); while ((index = copystr.indexOf(searchStr, startIndex)) &gt; -1) { searchS.add(index); startIndex = index + searchStrLen; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload