GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — abc/Interleaving String.java at master · stevencoding/abc

Expand file tree

/

Interleaving String.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
34 lines (34 loc) · 1.02 KB
/

Interleaving String.java

Copy path

File metadata and controls

34 lines (34 loc) · 1.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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.