public class Solution {
public boolean isSubsequence(String s, String t) {
int idx = 0;
for (int i=0; i<t.length()&&idx<s.length(); i++) {
if (s.charAt(idx) == t.charAt(i)) {
idx++;
}
}
return idx == s.length();
}
}

is-subsequence的更多相关文章

  1. [LeetCode] Arithmetic Slices II - Subsequence 算数切片之二 - 子序列

    A sequence of numbers is called arithmetic if it consists of at least three elements and if the diff ...

  2. [LeetCode] Is Subsequence 是子序列

    Given a string s and a string t, check if s is subsequence of t. You may assume that there is only l ...

  3. [LeetCode] Wiggle Subsequence 摆动子序列

    A sequence of numbers is called a wiggle sequence if the differences between successive numbers stri ...

  4. [LeetCode] Increasing Triplet Subsequence 递增的三元子序列

    Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the ar ...

  5. [LeetCode] Longest Increasing Subsequence 最长递增子序列

    Given an unsorted array of integers, find the length of longest increasing subsequence. For example, ...

  6. 动态规划求最长公共子序列(Longest Common Subsequence, LCS)

    1. 问题描述 子串应该比较好理解,至于什么是子序列,这里给出一个例子:有两个母串 cnblogs belong 比如序列bo, bg, lg在母串cnblogs与belong中都出现过并且出现顺序与 ...

  7. 【LeetCode】Increasing Triplet Subsequence(334)

    1. Description Given an unsorted array return whether an increasing subsequence of length 3 exists o ...

  8. CF724D. Dense Subsequence[贪心 字典序!]

    D. Dense Subsequence time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  9. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  10. [tem]Longest Increasing Subsequence(LIS)

    Longest Increasing Subsequence(LIS) 一个美丽的名字 非常经典的线性结构dp [朴素]:O(n^2) d(i)=max{0,d(j) :j<i&& ...

随机推荐

  1. Ionic 自动创建应用的图标与启动画面

    你只需要一个目录和两张图片就可以搞定.图片可以是 .png 的,Photoshop的 .psd,或者Illustrator的 .ai,(例如)命名为icon.png和splash.png.把这些图片放 ...

  2. MongoDB入门教程二[MongoDB Shell 简介与使用]

    MongoDB Shell 是MongoDB自带的JavaScript Shell,随MongoDB一同发布,它是MonoDB客户端工具,可以在Shell中使用命令与MongoDB实例交互,对数据库的 ...

  3. OpenCV 基础笔记

    本文大部分内容来源于入门者的Python快速教程 - 番外篇之Python-OpenCV 本篇将介绍和深度学习数据处理阶段最相关的基础使用,并完成4个有趣实用的小例子: 延时摄影小程序 视频中截屏采样 ...

  4. python数据分析之csv/txt数据的导入和保存

    约定: import numpy as np import pandas as pd 1 2 3 一.CSV数据的导入和保存 csv数据一般格式为逗号分隔,可在excel中打开展示. 示例 data1 ...

  5. 在Windows上安装FFmpeg程序

    原文地址:http://helloway.blog.51cto.com/7666282/1642247 FFmpeg是一套可以用来记录.转换数字音频.视频,并能将其转化为流的开源计算机程序.它提供了录 ...

  6. LNMP一键安装包如何重装Nginx

    LNMP一键安装包安装好后,相应的Mysql,Nginx及PHP都会安装配置完成. 由于某些特殊情况的需要,如何更换Nginx的版本呢? nginx升级脚本可以完成. 1. 手动编译方法:/usr/l ...

  7. Express中间件

    一.编写中间件 中间件函数能够访问请求对象(req),响应对象(res),应用程序的请求/响应循环中的下一个中间件函数.下一个中间件函数通常由名为next的变量来表示. 中间件函数可以执行以下任务: ...

  8. Codeforces Round #281 (Div. 2) C. Vasya and Basketball 暴力水题

    C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  9. ThinkPHP实现登录限制时__construct和_initialize的区别

    ThinkPHP支持两种构造方法:  __construct和_initialize(ThinkPHP内置的构造方法). 测试URL为:  http://oa.com/index.php/Admin/ ...

  10. MySQL优化器的成本模型

    http://www.orczhou.com/index.php/2016/08/mysql-optimizer-cost-model-1/V