随笔分类 - +-*/
摘要:Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".StringBuilder + reverse methodpublic class Solution { public String addBinary(String a, String b) { if(a == null || a.equals("")) return b; if(b == null || b
阅读全文
摘要:Implementint sqrt(int x).Compute and return the square root ofx.public class Solution { public int sqrt(int x) { int start = 0; int end = x; if(x == 0 || x == 1) return x; while(start x/m){ end = m -1; }else{ s...
阅读全文
摘要:public class Solution { public int divide(int dividend, int divisor) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance will be reused for each test case. if(dividend == 0) return 0; if(divisor == 1) return...
阅读全文
摘要:123 * 45 615 + 492 = 5535public class Solution { public String multiply(String num1, String num2) { int l1 = num1.l...
阅读全文
摘要:public class Solution { public double pow(double x, int n) { if(n<0){ return 1.0/powHelper(x,n); }else{ return powHelper(x, n); } } public double powHelper(double x, int n){ if(n == 0){ return 1; } double...
阅读全文

浙公网安备 33010602011771号