# Overview

It seems that coding tests are conducted overseas in interviews with engineers, and in many cases, the main thing is to implement specific functions and classes according to the theme.

Apparently, many engineers take measures on the site called LetCode.

It is a site that trains the algorithmic power that can withstand the coding test that is being done in the early story, and it is an inevitable path for those who want to build a career at an overseas tech company.

I wrote it in a big way, but I have no plans to have such an interview at the moment.

However, as an IT engineer, it would be better to have the same level of algorithm power as a person, so I would like to solve the problem irregularly and write down the method I thought at that time as a memo.

Leetcode

I'm solving it with Python3.

** Technical Blog Started! !! ** ** I think the technology will write about LetCode, Django, Nuxt, and so on. ** This is faster to update **, so please bookmark it!

# problem

392. Is Subsequence The difficulty level is Easy.

It is an excerpt from the problem collection as before.

The problem is, given the string s and the string t, find out if s is a partial continuity of t.

The partial continuity of the character string here is a new character string formed by deleting a part of the character from the original character string without breaking the relative position of the remaining characters. (You don't have to do anything). (For example, "ace" is a substring of "abcde", but "aec" is not).

Example 1:

Input: s = "abc", t = "ahbgdc" Output: true

Example 2:

Input: s = "axc", t = "ahbgdc" Output: false

# solution

``````class Solution:
def isSubsequence(self, s: str, t: str) -> bool:
pre = cur = 0
while pre < len(s) and cur < len(t):
if s[pre] == t[cur]:
pre +=1
cur +=1
return pre == len(s)
# Runtime: 36 ms, faster than 60.46% of Python3 online submissions for Is Subsequence.
# Memory Usage: 14.1 MB, less than 35.95% of Python3 online submissions for Is Subsequence.
``````

I took the form of thinking using two pointers.

If the `pre` index of` s` is the `cur` index of t, that is, by increasing the value of` pre` when a substring is found, and otherwise increasing the value on the `cur` side. You can shift the index of, `t`. Continue this for less than the length of `s` and` t`, respectively, for `pre` and` cur`. If the value of `pre` does not match the length of` s`, then `False`, In other cases, it returns `True`.

It's not an algorithm, but I think there are various ways to do it, as it was a problem to think about comprehensively, but this time it looks like this.

So that's it for this time. Thank you for your hard work.