Skip to content

Instantly share code, notes, and snippets.

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();
int k=s3.length();
if(k!=(n+m)) return false;
boolean S[][]=new boolean[m+1][n+1];
S[0][0]=true;
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; next = null; }
* }
*/
/**
* Definition for binary tree
/**
* Definition for binary tree
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
/**
* Definition for binary tree
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
/**
* Definition for binary tree
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public class Solution {
public String multiply(String num1, String num2) {
// Start typing your Java solution below
// DO NOT write main() function
if(num1.compareTo("0")==0 || num2.compareTo("0")==0 ) return "0";
int length1=num1.length(); int length2=num2.length();
int [] array=new int [length1+length2];
int carry=0;
for(int i=length1-1; i>=0; i--)
{
public class Solution {
public int trap(int[] A) {
// Start typing your Java solution below
// DO NOT write main() function
int length=A.length;
if(length==0|| length==1) return 0;
int [] leftMost=new int [length]; int tempL=A[0];
int [] rightMost=new int[length]; int tempR=A[length-1];
int sum=0;
//first pass which stores the right most value
public class Solution {
public String countAndSay(int n) {
// Start typing your Java solution below
// DO NOT write main() function
String result="1";
while(n>1)
{
int length=result.length();
StringBuffer sb=new StringBuffer();
int count=1;
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
// Test.java
import java.util.Comparator;
import java.util.PriorityQueue;
public class Test
{
public static void main(String[] args)
{
Comparator<String> comparator = new StringLengthComparator();
PriorityQueue<String> queue =