原题地址:https://oj.leetcode.com/problems/add-binary/ 题意: Given two binary strings, return their sum (also a binary string). For example,a = "11"b ...
Given two binary strings, return their sum also a binary string . For example,a b Return . 这题用数组来做可能更简单,但考虑到可能面试的时候要求不能开额外的数组,就只能对string操作了。最主要的是把进位这部分写对。 ...
2012-10-27 19:23 0 4023 推荐指数:
原题地址:https://oj.leetcode.com/problems/add-binary/ 题意: Given two binary strings, return their sum (also a binary string). For example,a = "11"b ...
题目: Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 题解: 二进制加法都是从最低位(从右加到左)。所以对 ...
Add Binary Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 先进行对齐操作,然后从右往左逐位相加,注意进位 ...
Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters 1 or 0. ...
Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 二进制数相加,并且保存在string中,要注意的是如何将string ...
问题:给一个二叉树,写一个算法判断这个树是不是balanced。 Solution #1. 第一次遇到这个问题时我的解法,如下: 写了一个getDepth()函数,访问每个节点都要调用一次这个函数。这个Solution也通过了leetcode的验证程序,但是后来想了想,I ...
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which ...
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node ...