一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". (二)解题 题意很简单,实现二进制加法逻辑…
二进制加法 https://discuss.leetcode.com/topic/33693/another-simple-java public String addBinary(String a, String b) { if(a==null||b==null){ return a==null?b:a; //如果其中一个为null,则返回另一个:结合着if条件语句可以包括两个都是null的情形 } int alen = a.length()-1; int blen = b.length()-…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 BigInteger类 模拟加法 日期 题目地址:https://leetcode.com/problems/add-binary/description/ 题目描述 Given two binary strings, return their sum (also a binary string). The input strings are bot…
题目: Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 提示: 此题我的第一反应是把输入的两个字符串转化为数字,相加以后再把结果转化为二进制输出,但是测试用例中会有很大的输入,此时即使是long long型也会造成溢出,所以只能用最传统的由低位到高位逐位相加的方法去做. 代码: c…
题目描述: There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the ith round, you toggle e…