GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — abc/Interleaving String.java at master · stevencoding/abc Expand file tree/ Copy pathInterleaving String.javaMore file actions 34 lines (34 loc) · 1.02 KB / Copy pathInterleaving String.javaFile metadata and controls34 lines (34 loc) · 1.02 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 public class Solution { public boolean isInterleave(String s1, String s2, String s3) { // Start typing your Java solution below // DO NOT write main() function int m=s1.length(); int n=s2.length(); if((m+n)!=s3.length()) return false; boolean [][] checker=new boolean [m+1][n+1]; checker[0][0]=true; for(int i=0; i<m; i++) { if(s1.charAt(i)==s3.charAt(i)) { checker[i+1][0]=true; }else break; } for(int i=0; i<n; i++) { if(s2.charAt(i)==s3.charAt(i)) { checker[0][i+1]=true; }else break; } for(int i=1; i<=m; i++) { for(int j=1; j<=n; j++) { if(checker[i][j-1]&&s3.charAt(i+j-1)==s2.charAt(j-1)) checker[i][j]=true; else if (checker[i-1][j]&&s3.charAt(i+j-1)==s1.charAt(i-1)) checker[i][j]=true;; } } return checker[m][n]; } } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |