博客专栏  >  编程语言   >  LeetCode

LeetCode

leetcode题解

关注
0 已关注
17篇博文
  • 弗洛伊德判圈算法

    先来看链表是否有环的判断 设链表起始节点为H,回路起始节点为S,两指针第一次相遇节点为M。 设回路的长度为c,S到M的距离为c1,M到S的距离为c2。 设H到S的距离为d。 设hare每次移动2,to...

    2015-10-08 21:29
    1289
  • 二分搜索

    Sqrt(x)   Implement int sqrt(int x). Compute and return the square root of x.

    2015-04-01 18:20
    345
  • LRU cache

    实现lru 缓存 LRU Cache  Total Accepted: 35641 Total Submissions: 241374My Submissions Question  S...

    2015-04-09 15:28
    712
  • 层次遍历二叉树

    public class Solution { static class Queue { static final int MAX_SIZE = 1 << 10; ...

    2015-04-10 17:29
    497
  • 复制无向带环图

    Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. ...

    2015-04-13 16:06
    659
  • BST迭代器

    Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the ro...

    2015-04-16 16:19
    670
  • 先序和中序建立二叉树

    Construct Binary Tree from Preorder and Inorder Traversal   Given preorder and inorder trave...

    2015-04-23 12:50
    1036
  • 变位分词

    static int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73...

    2015-04-24 22:44
    477
  • 判断二叉树是否对称

    static boolean isMirror(TreeNode left, TreeNode right) { if (left == null && right == null) ...

    2015-04-24 21:42
    974
  • 求二叉树最远距离

    int max=Integer.MIN_VALUE; int maxHeightSum(TreeNode root) { if (root == null) return 0...

    2015-04-25 19:14
    461
  • 文件路径化简

    Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", => "/...

    2015-04-29 16:37
    441
  • 平衡二叉树判定

    1. int height(TreeNode root) { if (root == null) return 0; return Math.max(height(ro...

    2015-04-29 18:44
    407
  • 将升序数组转化为平衡二叉树

    public class Solution { TreeNode convert(int num[], int l, int r) { if (l >= r) return n...

    2015-04-29 20:13
    832
  • Best Time to Buy and Sell Stock IV

    Say you have an array for which the ith element is the price of a given stock on day i. Design an a...

    2015-05-03 14:43
    698
  • N皇后问题

    The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens ...

    2015-05-10 12:57
    404
  • 用dfs实现拓扑排序

    拓扑排序,详见算法导论 There are a total of n courses you have to take, labeled from 0 to n - 1. Some cours...

    2015-05-16 00:27
    521
  • 有向图判断是否有环

    There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have...

    2015-05-13 23:41
    452
img博客搬家
img撰写博客
img发布 Chat
img专家申请
img意见反馈
img返回顶部