substring

[LeetCode] Longest Duplicate Substring

倖福魔咒の 提交于 2020-01-18 03:30:29
Given a string S, consider all duplicated substrings: (contiguous) substrings of S that occur 2 or more times. (The occurrences may overlap.) Return any duplicated substring that has the longest possible length. (If S does not have a duplicated substring, the answer is "".) Example 1: Input: "banana" Output: "ana" Example 2: Input: "abcd" Output: "" Note: 2 <= S.length <= 10^5 S consists of lowercase English letters. 来自leetcode官方的题解: https://leetcode-cn.com/problems/longest-duplicate-substring/solution/zui-chang-zhong-fu-zi-chuan-by-leetcode/ 方法一:二分查找 + Rabin-Karp 字符串编码 分析 我们可以把这个问题分解成两个子问题: 从

Extract part of a text file for usage in vb.net

流过昼夜 提交于 2020-01-17 18:49:32
问题 Ok. I need to store some records in a file namely data.dat . Records in the file are sorted by date values. Each block of record starts with its date value along with a $ sign to indicate that a new block of record starts here and ends with a "#" sign to indicate end of the record block. A sample of a record block would be: $22/08/2013 (data) (data) (data) # The file data.dat contains several blocks like this, how can I extract each block in the file storing each in an array using vb.net? 回答1

Extract part of a text file for usage in vb.net

心不动则不痛 提交于 2020-01-17 18:41:09
问题 Ok. I need to store some records in a file namely data.dat . Records in the file are sorted by date values. Each block of record starts with its date value along with a $ sign to indicate that a new block of record starts here and ends with a "#" sign to indicate end of the record block. A sample of a record block would be: $22/08/2013 (data) (data) (data) # The file data.dat contains several blocks like this, how can I extract each block in the file storing each in an array using vb.net? 回答1

Perl critic policy violation in checking index of substring in a string

风流意气都作罢 提交于 2020-01-17 15:21:31
问题 for my $item (@array) { if (index($item, '$n') != -1) { print "HELLO\n"; } } Problem is: Perl critic gives below policy violation. String may require interpolation at line 168, near '$item, '$n''. (Severity: 1) Please advise how do I fix this? 回答1: In this case the analyzer either found a bug or is plain wrong in flagging your code. Are you looking for a literal " $n " in $item , or for what $n variable evaluates to? If you want to find the literal $n characters then there is nothing wrong

Search SQL Server string for values from another table

爱⌒轻易说出口 提交于 2020-01-17 13:27:34
问题 I have a table with column name that has random characters before and after the name ie: Table A : Name ----------------- asd4345JONlkj345 .;lidDavidlksd$ and I have another table in same DB that has the names ie: Table B : Name ------ David Jon This goes on like this for 30k rows or I'd just hardcode something really quick. I want to search each string in Table A 'Name' column for each value from Table B, and if found return the name in a new column. I have a feeling this will be a UDF,

Search SQL Server string for values from another table

谁说胖子不能爱 提交于 2020-01-17 13:27:10
问题 I have a table with column name that has random characters before and after the name ie: Table A : Name ----------------- asd4345JONlkj345 .;lidDavidlksd$ and I have another table in same DB that has the names ie: Table B : Name ------ David Jon This goes on like this for 30k rows or I'd just hardcode something really quick. I want to search each string in Table A 'Name' column for each value from Table B, and if found return the name in a new column. I have a feeling this will be a UDF,

How do you search a string in Irvine Assembly Language and replace it with a substring?

落爺英雄遲暮 提交于 2020-01-17 03:34:07
问题 I am writing a program that reads a string then searches for certain keywords, like "cat", and replaces it with "dog". I am just unsure as how to start it. What code will I have to use? 回答1: For 8-bit characters it's broadly like this, there are many ways to implement it: Set si to point to the first character of the string. mov al,[si] repnz scasb to find the first match of the first character. Store the address somewhere. Set di to point to the first character of the replacement string (

Help with this ragged array/substring program in C?

♀尐吖头ヾ 提交于 2020-01-16 14:40:08
问题 so, I have a ragged array (called names) of length 200. each pointer in the array points to a string that is no longer than 50 characters and has no white spaces. I also have a string given through user-input called inname, with length 50, inname will be one of the strings stored in names. I need to find a way to go through the strings in my ragged array and find the string with the largest substring overlap with inname, excluding inname itself as that will be in the file. If no string has an

very specific substring retrieval and split

半腔热情 提交于 2020-01-16 05:27:09
问题 i know there are tons of posts about sub-stringing, believe me i have searched through many of them looking for an answer to this. i have many strings, lines from a log, and i am trying to categorize and parse them. they look something like this: /long/file/name/with.dots.and.extension:Jan 01 12:00:00 TYPE Static Message;Dynamic Message where the filename is the file where the log is located, the date is the date/time that the message was put into the log, and the TYPE is the type of message,

return index of the first letter of a specific substring of a string

北战南征 提交于 2020-01-16 01:28:25
问题 I am given a string and I wish to find out the index of the first character of a substring of that string whenever it appears the very first time in the parent string. For example, given a string "itiswhatitis" and the substring "is", the output should be 2. 回答1: You can use as below int indexOf(String str) from your example string. String s ="itiswhatitis"; int index = s.indexOf("is"); 回答2: "itiswhatitis".indexOf("is") Try this 回答3: public static void main(String[] args) { int index =