IT大道IT大道

首页 > TAG信息列表 > LeetCode

  • [LeetCode] 72. Edit Distance(最短编辑距离)

    [LeetCode] 72. Edit Distance(最短编辑距离)

    传送门DescriptionGiven two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You...

    2017-08-23 itdadao 技术 28 ℃ 0
  • Leetcode 之 Set Mismatch

    Leetcode 之 Set Mismatch


    645. Set Mismatch
    1.Problem

    The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got du...

    2017-08-23 itdadao 技术 35 ℃ 0
  • [LeetCode] Lowest Common Ancestor of a Binary Search Tree

    [LeetCode] Lowest Common Ancestor of a Binary Search Tree

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.
    According to the definition of LCA on Wikipedia: “The lo...

    2017-08-23 itdadao 技术 26 ℃ 0
  • 2018今日头条笔试(第二题)

    2018今日头条笔试(第二题)

    题目描述给定一个数组序列,需要选出一个区间,使得该区间是所有区间中经过如下计算的值最大的一个。区间中的最小数 * 区间所有数的和最后程序输出经过计算后的最大值即可,不需...

    2017-08-23 itdadao 技术 63 ℃ 0
  • leetcode 417. Pacific Atlantic Water Flow

    leetcode 417. Pacific Atlantic Water Flow

    Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of t...

    2017-08-22 itdadao 技术 30 ℃ 0
  • LeetCode: 566 Reshape the Matrix

    LeetCode: 566 Reshape the Matrix

    题目:
    In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.
    You'...

    2017-08-22 itdadao 技术 27 ℃ 0
  • LeetCode解题思路:344. Reverse String

    LeetCode解题思路:344. Reverse String

    Write a function that takes a string as input and returns the string reversed.
    Example:
    Given s = "hello", return "olleh".
    题意:翻转字符串,从头到尾翻转。
    基本思路...

    2017-08-22 itdadao 技术 31 ℃ 0
  • 18. 4Sum(中等)

    18. 4Sum(中等)

    Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives th...

    2017-08-22 itdadao 技术 33 ℃ 0
  • leetcode — remove-duplicates-from-sorted-array-ii

    leetcode — remove-duplicates-from-sorted-array-ii

    /**
    * Source : https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/
    *
    * Created by lverpeng on 2017/7/28.
    *
    * Follow up for "Remove Dup...

    2017-08-22 itdadao 技术 34 ℃ 0
  • Two Sum IV

    Two Sum IV

    Problem
    Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.
    Exa...

    2017-08-22 itdadao 技术 34 ℃ 0
  • LeetCode解题思路:566. Reshape the Matrix

    LeetCode解题思路:566. Reshape the Matrix

    题意:把一个矩阵变形成另一个矩阵,如3*4变成2*6。
    基本思路:
    1. 把矩阵中所有元素放在一个一维数组中,然后把一位数组中的数保存在新矩阵中。
    2.1中思路并没有什么问题,但是用了...

    2017-08-21 itdadao 技术 30 ℃ 0
  • leetcode — reverse-nodes-in-k-group

    leetcode — reverse-nodes-in-k-group

    /**
    * Source : https://oj.leetcode.com/problems/reverse-nodes-in-k-group/
    *
    * Created by lverpeng on 2017/7/12.
    *
    * Given a linked list, reverse the nodes...

    2017-08-21 itdadao 技术 24 ℃ 0
  • [LeetCode] 477. Total Hamming Distance(位操作)

    [LeetCode] 477. Total Hamming Distance(位操作)

    传送门DescriptionThe Hamming distance between two integers is the number of positions at which the corresponding bits are different.Now your job is to find the...

    2017-08-20 itdadao 技术 29 ℃ 0
  • leetcode 663. Equal Tree Partition

    leetcode 663. Equal Tree Partition

    Given a binary tree with n nodes, your task is to check if it's possible to partition the tree to two trees which have the equal sum of values after removing ex...

    2017-08-20 itdadao 技术 49 ℃ 0
  • LeetCode: 476 Number Complement(easy)

    LeetCode: 476 Number Complement(easy)

    题目:
    Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.
       Note:


    The given i...

    2017-08-20 itdadao 技术 25 ℃ 0
  • [leetcode-663-Equal Tree Partition]

    [leetcode-663-Equal Tree Partition]

    Given a binary tree with n nodes, your task is to check if it's possible to partition the tree to two trees which have the equal sum of values after removing ex...

    2017-08-20 itdadao 技术 78 ℃ 0
  • leetcode--(36. Valid Sudoku)

    leetcode--(36. Valid Sudoku)

    描述:9*9的方格,每一行每一列必须是1~9,每一个单元的3*3方格必须是1~9

    func isValidSudoku(board [][]byte) bool {
    //定义3个二维数组用来分别标记每一行,每一列,每一3*3单元格...

    2017-08-20 itdadao 技术 43 ℃ 0
  • [LeetCode] 421. Maximum XOR of Two Numbers in an Array(位操作)

    [LeetCode] 421. Maximum XOR of Two Numbers in an Array(位操作)

    传送门DescriptionGiven a non-empty array of numbers, a0, a1, a2, &hellip; , an-1, where 0 &le; ai < 231.Find the maximum result of ai XOR aj, where 0 &le; i, j...

    2017-08-19 itdadao 技术 26 ℃ 0
  • LeetCode解题思路:575. Distribute Candies

    LeetCode解题思路:575. Distribute Candies

    Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the correspo...

    2017-08-19 itdadao 技术 31 ℃ 0
  • 515. Find Largest Value in Each Tree Row 二叉树每一层的最大值

    515. Find Largest Value in Each Tree Row 二叉树每一层的最大值

    You need to find the largest value in each row of a binary tree.Example:
    Input:

    1
    / \
    3 2
    / \ \
    5 3 9

    Outp...

    2017-08-19 itdadao 技术 26 ℃ 0
  • 程序员面试金典-整数对查找

    程序员面试金典-整数对查找

    程序员面试金典-整数对查找

    链接:https://www.nowcoder.com/questionTerminal/87d5a092a1d647479103e519a6c0a205
    来源:牛客网


    请设计一个高效算法,找出数组中两数之和为指...

    2017-08-19 itdadao 技术 24 ℃ 0
  • 73. Set Matrix Zeroes(中等)

    73. Set Matrix Zeroes(中等)

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.

    重点是空间复杂度限制为常数.
    人家想法:

    用 matrix 的第0行和第0列的元素...

    2017-08-19 itdadao 技术 27 ℃ 0
  • leetcode — swap-nodes-in-pairs

    leetcode — swap-nodes-in-pairs

    /**
    * Source : https://oj.leetcode.com/problems/swap-nodes-in-pairs/
    *
    * Created by lverpeng on 2017/7/12.
    *
    * Given a linked list, swap every two adjacent...

    2017-08-19 itdadao 技术 30 ℃ 0
  • 15. 3Sum(中等)

    15. 3Sum(中等)

    Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
    Note...

    2017-08-18 itdadao 技术 24 ℃ 0
  • LeetCode解题思路:557. Reverse Words in a String III

    LeetCode解题思路:557. Reverse Words in a String III

    Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
    Example 1:...

    2017-08-18 itdadao 技术 29 ℃ 0
 10207    1 2 3 4 5 6 7 8 9 10 下一页 尾页
标签列表