Java 7ms Solution


  • 0
    N

    public class Solution {
    public String complexNumberMultiply(String a, String b) {
    String[] m=new String[2];
    String[] n=new String[2];
    m=a.split("\+");
    n=b.split("\+");
    int a1=(int)Integer.parseInt(m[0]);
    int a2=(int)Integer.parseInt(m[1].substring(0,m[1].length()-1));
    int a3=(int)Integer.parseInt(n[0]);
    int a4=(int)Integer.parseInt(n[1].substring(0,n[1].length()-1));
    int j=a1a3-a2a4;
    int k=a1a4+a2a3;
    return j+"+"+k+"i";
    }
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.