Tags » Substring

Suffix Array: Longest(All) Repeated Substring

Compare Function According to Length:

#include <set>

using namespace std;


struct stringcomp {
  bool operator() (const string& lhs, const string& rhs) const
  {return lhs.length()>=rhs.length();}
};
… 427 more words
Helpful API

Java substring (basics)

    public static void main(String[] args) {

        //substring(beginIndex)
        //substring(beginIndexIncluding,endIndexExcluding);

        String s = "0123456789";
        System.out.println("'" + s.substring(0) + "'");
        System.out.println("'" + s.substring(1) + "'");
        System.out.println("'" + s.substring(10) + "'");
        System.out.println("'" + s.substring(0, 0) + "'");
        System.out.println("'" + s.substring(0, 1) + "'");
        System.out.println("'" + s.substring(0, 10) + "'");
    }

Output:
'0123456789'
'123456789'
''
''
'0'
'0123456789'

Java

132 Palindrome Partitioning II

Given a string s, partition s such that every substring of the partition is a palindrome.

Return the minimum cuts needed for a palindrome partitioning of s. 17 more words

Leetcode

131 Palindrome Partitioning

Given a string s, partition s such that every substring of the partition is a palindrome.

Return all possible palindrome partitioning of s.

For example, given s = … 7 more words

Leetcode

5 Longest Palindromic Substring

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.

Leetcode

Transact SQL and the C Level Programmer ( String Casing and Indexes )

Background

Again, back reviewing code and saw yet another interesting one.

The code looks like this:


select username
from   .
where  LOWER(lastname) = LOWER(@lastname)

Thinking… 593 more words

Microsoft

Find index of last occurrence of a sub-string using SQL Server

-- Find Index from the String
select (LEN('0000000000000045') - CHARINDEX('0',Reverse('0000000000000045')) + 1) as FindIndex

-- Using Regx(if after the value is zero(0)
SELECT PATINDEX('%[^0]%','0000000000000450000')


-- Fetch Value except before Zero(0)
SELECT reverse(left(reverse('0000000000000045'), charindex('0', reverse('0000000000000045')) -1)) as FetchValueExceptZero



select REVERSE(SUBSTRING(REVERSE('000000000045'),0,CHARINDEX('0',REVERSE('000000000045')))) as FetchValueExceptZero

-- Using Regx(if after the value is zero(0)
select substring('0000000000000450000',patindex('%[^0]%','0000000000000450000'),Len('0000000000000450000'))
SQL Server