
LeetCode
文章平均质量分 50
刘小妞
遇见更好的自己---前端小白的成长历程,学的越多,发现自己越无知
展开
-
[leetcode] 371. Sum of Two Integers 解题报告
题目链接: https://leetcode.com/problems/sum-of-two-integers/ Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example: Given a = 1 and b = 2, retu转载 2016-08-16 14:45:20 · 363 阅读 · 0 评论 -
LeetCode:Add Digits - 非负整数各位相加
原文网址:http://my.oschina.net/Tsybius2014/blog/497645 1、题目名称 Add Digits (非负整数各位相加) 2、题目地址 https://leetcode.com/problems/add-digits 3、题目内容 英文:Given a non-negative integer num, repeatedly add all its转载 2016-08-16 15:38:57 · 426 阅读 · 0 评论 -
【数组】Majority Element II
题目:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.思路:首先,我们来看一下怎样求众数,也就是元素出现大于⌊ n/2 ⌋的数。我们注意到这样一个现象: 在转载 2016-08-16 20:45:23 · 296 阅读 · 0 评论 -
[leetcode] Linked List Cycle
Problem: Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? https://oj.leetcode.com/problems/linked-list-cycle/ Problem II: Gi转载 2016-08-27 14:29:39 · 416 阅读 · 0 评论 -
Leetcode---Majority element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. 在一个数组中,出现次数大于n/2次数的只可能有一个。开始时count为0,如果数组中的数和candidate相同,则加1。如果不同,则减1。cla原创 2016-08-19 16:43:11 · 259 阅读 · 0 评论