Manacher's Algorithm

karthikeya Boyini
Updated on 15-Jun-2020 18:40:57

718 Views

To find the longest palindromic substring from a string, we can use Manacher’s Algorithm. By selecting each character, we will try to find if there any palindrome using left and right pointer. There is another array to store information, from that information we can easily find how long the palindrome is. For each character, the array will store information. After traversing the whole string, we can find the longest palindromic subsequence from the created array.The time complexity of this algorithm is O(n).Input and OutputInput: String: “levelup” Output: Longest palindrome is: levelAlgorithmlongestPalindrome(text)Input − The text to find the longest palindromeOutput − ... Read More

Stretch Gathered Items on Different Screens in Bootstrap 4

Ricky Barnes
Updated on 15-Jun-2020 18:37:35

128 Views

Use the .align-content-*-stretch in Bootstrap 4 to stretch gathered items on different screens.To stretch items on different screens −Stretch items on Small Screen   Work 1   Work 2   Work 3   Work 4   Work 5   Work 6 Stretch items on Medium Screen   Work 1   Work 2   Work 3   Work 4   Work 5   Work 6 Stretch items on Large Screen   Work 1   Work 2   Work 3   Work 4   Work 5   Work 6 Let us see an example to stretch gathered items on different screen size ... Read More

Naive Pattern Searching

Sharon Christine
Updated on 15-Jun-2020 18:34:58

6K+ Views

Naïve pattern searching is the simplest method among other pattern searching algorithms. It checks for all character of the main string to the pattern. This algorithm is helpful for smaller texts. It does not need any pre-processing phases. We can find substring by checking once for the string. It also does not occupy extra space to perform the operation.The time complexity of Naïve Pattern Search method is O(m*n). The m is the size of pattern and n is the size of the main string.Input and OutputInput: Main String: “ABAAABCDBBABCDDEBCABC”, pattern: “ABC” Output: Pattern found at position: 4 Pattern found at ... Read More

Hide Bootstrap Modal Event

Amit Diwan
Updated on 15-Jun-2020 17:52:24

715 Views

The hide.bs.modal event in Bootstrap fires when the modal is about to be hidden.The following button hides the modal −   Click to hide Just after clicking the hide button, the hide.bs.modal event fires and before the modal is hidden.  Here is the script for the hide.bs.modal event:$("#newModal").on('hide.bs.modal', function () {   alert('The modal is about to be hidden.'); });The following is the complete example to implement the hide.bs.modal event in Bootstrap −ExampleLive Demo       Bootstrap Example                           ... Read More

Bootstrap 4 Class for Single Flex Item to Take Up Available Space

Alex Onsman
Updated on 15-Jun-2020 17:49:44

328 Views

In Bootstrap 4, if you want a flex item to take up the available space, then use the flex-grow-|1 class.If you want the first flex item to take up the space, then the following is the code −   One   Two   Three Above you can see, I have used the flex-grow-1 class in the first div class −   One The following is an example to implement the flex-grow-0|1 class −ExampleLive Demo      Bootstrap Example                      

Anagram Pattern Search

karthikeya Boyini
Updated on 15-Jun-2020 17:47:44

594 Views

Anagrams are basically all permutations of a given string or pattern. This pattern searching algorithm is slightly different. In this case, not only the exact pattern is searched, it searches all possible arrangements of the given pattern in the text.To solve this problem, we will divide the whole texts into several windows of length same as patterns. Then count on each character of the pattern is found and stored in an array. For each window, we also try to find the count array, then check whether they are matching or not.The time Complexity of Anagram Pattern Search Algorithm is O(n).Input ... Read More

Bad Character Heuristic

Sharon Christine
Updated on 15-Jun-2020 17:45:08

1K+ Views

The bad character heuristic method is one of the approaches of Boyer Moore Algorithm. Another approach is Good Suffix Heuristic. In this method we will try to find a bad character, that means a character of the main string, which is not matching with the pattern. When the mismatch has occurred, we will shift the entire pattern until the mismatch becomes a match, otherwise, pattern moves past the bad character.Here the time complexity is O(m/n) for best case and O(mn)for the worst case, where n is the length of the text and m is the length of the pattern.Input and ... Read More

Set a Dark Border to an Element in Bootstrap

David Meador
Updated on 15-Jun-2020 17:35:15

146 Views

If you want to set a dark border to an element, use the border-dark class.Spot the difference between a normal border and dark border −To add a dark border, you need to simply add it like any other class in div as shown below −   Dark Border Above, the test is the CSS style, I have used to style my rectangle (div) −.myclass {   width: 150px;   height: 150px;   margin: 35px; }Let us see how to work with the border-dark class in Bootstrap 4 −ExampleLive Demo       Bootstrap Example       ... Read More

Border Info Class in Bootstrap 4

David Meador
Updated on 15-Jun-2020 17:32:38

206 Views

Use the border-info class in Bootstrap, to set a border that indicates information. Set the class as if you use any other class in Bootstrap:   Details Above, we added border-info class. Another class, “one” is used to give shape to the div element −.one {   width: 180px;   height: 180px;   margin: 55px; }You can try to run the following code to implement the border-info class on a rectangle −ExampleLive Demo      Bootstrap Example                            .one {      width: 180px;      height: 180px;      margin: 55px;    }         Rectangle with a border to set information:   Details

Efficient Construction of Finite Automata

Sharon Christine
Updated on 15-Jun-2020 17:31:15

1K+ Views

By constructing Finite Automata, we can simply perform the pattern searching in texts. At first, we have to fill a 2D array to make the transition table of the finite automata. Once the table is created, the searching procedure is simple. By starting from the first state of the automaton, when we reach the final state, it means that the pattern is found in the string.For finite automata construction, the time complexity is O(M*K), M is the pattern length and the K is a number of different characters. The complexity of main pattern searching is O(n).Input and OutputInput: Main String: ... Read More

Advertisements