Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.
For example,
Given:
s1 = "aabcc"
,
s2 = "dbbca"
,
When s3 = "aadbbcbcac"
, return true.
When s3 = "aadbbbaccc"
, return false.
public class Solution { public boolean isInterleave(String s1, String s2, String s3) { if (s1.length()+s2.length() != s3.length()) { return false; } boolean[][] res = new boolean[s1.length()+1][s2.length()+1]; res[0][0] = true; for (int i = 1; i <= s1.length() && s1.charAt(i-1) == s3.charAt(i-1); i++) { res[i][0] = true; } for (int i = 1; i <= s2.length() && s2.charAt(i-1) == s3.charAt(i-1); i++) { res[0][i] = true; } for (int i = 1; i <= s1.length(); i++) { for (int j = 1; j <= s2.length(); j++) { char charAt = s3.charAt(i+j-1); if (s1.charAt(i-1)==charAt && res[i-1][j]) { res[i][j] = true; } if (s2.charAt(j-1)==charAt && res[i][j-1]) { res[i][j] = true; } } } return res[s1.length()][s2.length()]; } }
相关推荐
Interleaving String Scramble String Minimum Path Sum Edit Distance Decode Ways Distinct Subsequences Word Break Word Break II Dungeon Game House Robber House Robber II House Robber III Range Sum Query...
leetcode 分类 ...Interleaving String Triangle Distinct Subsequences Decode Ways Palindrome Partitioning II Maximal Rectangle ###Recursion N-Queens N-Queens II Balanced Binary Tree Binar
97.Interleaving String, 115.Distinct Subsequences 2017/04/24 (Lintcode)92.Backpack, (Lintcode)125.Backpack II, (Lintcode)564.Backpack VI 不适用 53.Maximum Subarray, 91.Decode Ways, 96.Unique Binary ...
leetcode卡 OJ 题目汇总 记录下自己做过的oj题目, 也记录下自己对算法以及编程的理解与偏见. 杂感 算法到底是有用还是没用? 这个问题一直萦绕在我的心里. ...String动态规划解决, Recovering BST失败
Interleaving function using labview
Slice interleaving in compressed video packetization
QPSK MODUALTION WITH HELICAL INTERLEAVING of OFDM sysytem BER-bit error rate analisys. and trying to improve more BER
OFDM全过程,包括卷积、交织、上下变频以及信道
Downstream signal processing, synch, FEC, bit Mapping , interleaving, IDFT, CP
数据结构中用python实现两个单链表交叉插入,在LList类中
"interleaving_string.erl","search_insert_position.erl", "three_sum.erl","trapping_rain_water.erl", "valid_palindrome.erl" 个人认为dungeon_game这个题目解题逻辑很体现erlang的函数式的思维逻辑
非常好的ofdm误码率性能仿真代码,包含交织,预编码和空中检测
深衰落信道交织码的快速实现,非常适合初学者理解交织过程
包括turbo,polar,LDPC信道编码,交织,QAM,SCMA,MIMO检测,译码等
OFDM系统仿真,采用1024子载波,内含卷积编码,交织,QPSK调制,上、下采样滤波,信道估计等
信道编码中的交织与解交织技术的MATLAB仿真程序
构建CDMA通信系统,包括发送,交织,调制,解调,接收等模块
Herein, we Introduce packets Interleaving CCSDS file delivery protocol (PI-CFDP) developed to cope with frequent packet losses Inherent In deep-space communications. It is designed by applying ...
802.11ac中的交织编码,算法见书P68 运用到40MHZ信道时,第三次交织公式不匹配,只采用两次交织
Two Types of Zero Correlation Zone Sequence Pairs Set via Interleaving Perfect Sequence Pairs