
leetcode
cod16xx
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode-6(排列)
一、Permutations 给定一个包含不同数字数组,返回这些数字全部全排列 [1,2,3]=>[ [1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]class Solution(object): def permute(self, nums): """ :type nums: List[int]原创 2017-11-30 21:38:51 · 229 阅读 · 0 评论 -
LeetCode-2
一、Sum of Two Integers不使用 + - 号计算两个数的和 1.计算进位,carry=a&b 2.异或(半加法,不包含进位的加法)a=a^b 3.进位应该加在前一位,carry左移1位,b赋值为carry,直到b=0class Solution { public int getSum(int a, int b) { if (a==0) return b;原创 2017-11-26 19:13:18 · 306 阅读 · 0 评论 -
LeetCode-1
一、Single Number 给定一个整数的数组,每个数字出现两次,但有一个数字只出现了一次,找到这个单独的数字。class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ re原创 2017-11-26 16:13:34 · 217 阅读 · 0 评论 -
LeetCode-3(非递归前中后序遍历)
一、Top K Frequent Elements 给定一个不为空的数字数组,返回出现次数最高的前k个元素class Solution(object): def topKFrequent(self, nums, k): """ :type nums: List[int] :type k: int :rtype: List[in原创 2017-11-27 14:26:45 · 255 阅读 · 0 评论 -
LeetCode-4(Excel列号转换)
一、Top K Frequent Elements 给定一个不为空的数字数组,返回出现次数最高的前k个元素class Solution(object): def topKFrequent(self, nums, k): """ :type nums: List[int] :type k: int :rtype: List[in原创 2017-11-27 14:55:06 · 449 阅读 · 0 评论 -
LeetCode-5(反转链表I、II)
一、Reverse Linked List反转链表# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): #递归原创 2017-11-28 20:59:05 · 316 阅读 · 0 评论