标签:leetcode2018-07-29xindoo阅读(3744)评论(0)赞(0)
876. Middle of the Linked List 简单题,我的做法是先数下个数,然后知道中间节点是第几个了。2018-07-15xindoo阅读(4094)评论(0)赞(0)
868. Binary Gap 简单题,就是求一个数字二进制形式中两个1的最大间隔位置,比如22的二进制0b10110,最大距离就是2,0b100001,最大距离是5。2018-02-21xindoo阅读(3870)评论(0)赞(0)
题目链接295. Find Median from Data Stream 在一个有序数组中找中位数,但需要支持再数组中添加新的元素。本来是有序里的,可以很轻易就查到中位数,但如果添加新数字后,不一定有序。如果先对数组排序,那代价就比较...2017-11-19xindoo阅读(3915)评论(0)赞(0)
题目链接 236. Lowest Common Ancestor of a Binary Tree 根据LCA的定义,二叉树中最小公共祖先就是两个节点p和q最近的共同祖先节点,LCA的定义没什么好解释的,主要是这道题的解法。2017-10-31xindoo阅读(3940)评论(0)赞(0)
题目链接 Leetcode 4. Median of Two Sorted Arrays 题目描述很简单,就是找到两个有序数组合并后的中位数,要求时间复杂度O(log (m+n))。2017-07-31xindoo阅读(3789)评论(0)赞(0)
题目链接:19. Remove Nth Node From End of List 删除单链表中的倒数第n个节点,链表中删除节点很简单,但这道题你得先知道要删除哪个节点。在我的解法中,我先采用计数的方式来确定删除第几个节点。另外我在头节...2017-07-31xindoo阅读(3820)评论(0)赞(0)
题目链接 Leetcode 24. Swap Nodes in Pairs 给你一个链表,交换相邻两个节点,例如给你 1->2->3->4,输出2->1->4->3。2017-07-31xindoo阅读(3867)评论(0)赞(0)
原题链接:6.ZigZag Conversion 题目名称『曲折变换』,但给的样例只有三行,看不出到底怎么样曲折变化,所以这里我再补充一个样例,大家肯定一下就懂了。2017-06-22xindoo阅读(4076)评论(0)赞(0)
题目链接 Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of...2017-05-21xindoo阅读(3921)评论(0)赞(0)
Leetcode 582. Kill Process 好久没刷题,今天来一道比较简单的题目,如果此题作为一道面试题,可以延伸出树的遍历,栈和队列,hashmap,treemap等,还是比较能考验基础的面试题。2017-04-01xindoo阅读(3790)评论(0)赞(0)
Leetcode 114. Flatten Binary Tree to Linked List 题目意思很简单,就是把一棵二叉数转换为链表,虽然题目中没说以什么样的形式转换,但看下样例就很容易看出来,是以先序遍历的次序转换成链表。这里...2017-03-11xindoo阅读(3985)评论(0)赞(0)
Water and Jug Problem You are given two jugs with capacities x and y litres. There is an infinite amount of water supply...2017-02-25xindoo阅读(3762)评论(0)赞(0)
好久没刷题了,今天来俩道简单题。 Leetcode 62. Unique Paths Leetcode 63. Unique Paths II2016-12-10xindoo阅读(4380)评论(0)赞(0)
题目链接:Unique Substrings in Wraparound String 这里加段英文,不是为了凑字数,而是为了让别人搜索题目的时候能搜到我的博客。。 Consider the string s to be the infin...2016-11-05xindoo阅读(3772)评论(0)赞(0)
题目链接:368. Largest Divisible Subset Given a set of distinct positive integers, find the largest subset such that every pa...2016-08-07xindoo阅读(3854)评论(0)赞(0)
题目链接:53.Maximum Subarray Find the contiguous subarray within an array (containing at least one number) which has the lar...2016-08-06xindoo阅读(3798)评论(0)赞(0)
题目链接:Super Pow Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive ...2016-07-27xindoo阅读(3807)评论(0)赞(0)
题目链接:Combination Sum IV Given an integer array with all positive numbers and no duplicates, find the number of possible ...2016-07-10xindoo阅读(3798)评论(0)赞(0)
题目链接:Search a 2D Matrix II Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has th...2016-07-10xindoo阅读(3940)评论(0)赞(0)
题目链接:Search a 2D Matrix Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the f...2016-06-25xindoo阅读(3686)评论(0)赞(0)
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. 求一个二叉搜索树的第k小值。 题目链接:htt...2016-06-19xindoo阅读(4120)评论(2)赞(0)
Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are i...2016-06-14xindoo阅读(3936)评论(0)赞(0)
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are...2016-06-12xindoo阅读(4007)评论(2)赞(0)
Given a string, find the length of the longest substring without repeating characters. 原题链接:Longest Substring Without Re...