- 博客(8)
- 资源 (4)
- 收藏
- 关注
原创 Contiguous Array
Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.Example 1:Input: [0,1]Output: 2Explanation: [0, 1] is the longest contiguous subarray with
2017-03-28 15:39:08 424
原创 202. Happy Number
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares
2017-03-23 23:12:54 343
原创 35. Search Insert Position
问题:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the
2017-03-23 23:08:34 356
原创 Climbing Stairs
问题:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will
2017-03-23 23:03:19 269
原创 Add Strings
问题描述Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 contains only dig
2017-03-22 16:25:48 836
原创 Power of Three
问题描述:Given an integer, write a function to determine if it is a power of three.思路:给定一个整数,判断其是否是3的次幂,也就是求以3为底,n的对数是否是整数,即log3(n),若为整数,返回true,否则返回false,利用,loga(b)=log10(b)/log10(a),来进行转换,判断其是否
2017-03-22 15:44:39 370
原创 Power of two
问题Given an integer, write a function to determine if it is a power of two.solution1思路:对于纯数字的问题,可以试着用位操作的方法来进行解决,观察下所有2的幂次方的2进制数特征:1,10,100,1000.....所有的这些2进制数都是首位为1其余为0,这是一个很明显得特征,那么根据这个特征来
2017-03-21 23:21:18 289
原创 447. Number of Boomerangs
问题描述:Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the distance between iand j equals the distance between i and k (the
2017-03-01 21:51:36 405
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人