• lintcode 中等题:unique Binary Search Tree 不同的二叉查找树

    时间:2023-12-29 17:27:04

    题目不同的二叉查找树给出 n,问由 1...n 为节点组成的不同的二叉查找树有多少种?样例给出n = 3,有5种不同形态的二叉查找树:1 3 3 2 1 \ / / / \ \ 3 2 1...

  • [LintCode]——目录

    时间:2023-12-27 14:12:46

    Yet Another Source Code for LintCodeCurrent Status : 232AC / 289ALL in Language C++, Up to date (2016-02-10)For more problems and solutions, you can s...

  • 211. String Permutation【LintCode by java】

    时间:2023-12-27 13:34:04

    DescriptionGiven two strings, write a method to decide if one is a permutation of the other.Exampleabcd is a permutation of bcad, but abbe is not a pe...

  • Lintcode: Nth to Last Node in List

    时间:2023-12-22 16:28:11

    Find the nth to last element of a singly linked list. The minimum number of nodes in list is n.ExampleGiven a List ->->->->null and n = ,...

  • [LintCode] Invert Binary Tree 翻转二叉树

    时间:2023-12-13 16:46:27

    Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.ExampleGiven 4 points: (1,2), (3,6), (0,0), (1,3).T...

  • lintcode 中等题:Single number III 落单的数III

    时间:2023-12-09 19:18:47

    题目落单的数 III给出2*n + 2个的数字,除其中两个数字之外其他每个数字均出现两次,找到这两个数字。样例给出 [1,2,2,3,4,4,5,3],返回 1和5挑战O(n)时间复杂度,O(1)的额外空间复杂度解题根据落单的数I,可以想到,所有的数进行异或运行的结果就是所求两个数的异或结果。这个异...

  • Matrix Zigzag Traversal(LintCode)

    时间:2023-12-02 21:58:14

    Matrix Zigzag TraversalGiven a matrix of m x n elements (m rows, ncolumns), return all elements of the matrix in ZigZag-order.Have you met this questi...

  • Lintcode: Matrix Zigzag Traversal

    时间:2023-12-02 21:44:50

    Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in ZigZag-order.Have you met this question in a real interview...

  • LintCode "Delete Digits"

    时间:2023-12-02 13:38:42

    Greedy: remove earliest down-edge: like "54", "97".class Solution {public: /** *@param A: A positive integer which has N digits, A is a string....

  • lintcode-176-图中两个点之间的路线

    时间:2023-11-30 21:26:44

    176-图中两个点之间的路线给出一张有向图,设计一个算法判断两个点 s 与 t 之间是否存在路线。样例如下图:for s = B and t = E, return truefor s = D and t = C, return false标签Cracking The Coding Intervie...

  • LintCode Implement Queue by Two Stacks

    时间:2023-11-30 18:43:18

    1. stack(先进后出):pop 拿出并返回最后值; peek 返回最后值; push 加入新值在后面并返回此值。2. queue(先进先出) :poll = remove 拿出并返第一个值; element = peek 返第一个值; add = offer 加入新值在后面并返回true/fa...

  • lintcode 中等题:majority number III主元素III

    时间:2023-11-30 11:51:42

    题目主元素 III给定一个整型数组,找到主元素,它在数组中的出现次数严格大于数组元素个数的1/k。样例给出数组 [3,1,2,3,2,3,3,4,4,4] ,和 k = ,返回 3注意数组中只有唯一的主元素挑战要求时间复杂度为O(n),空间复杂度为O(k)解题上一题刚介绍过所用的方法,但是这个确实很...

  • lintcode :reverse integer 颠倒整数

    时间:2023-11-28 09:29:42

    题目:颠倒整数将一个整数中的数字进行颠倒,当颠倒后的整数溢出时,返回 0 (标记为 32 位整数)。样例给定 x = 123,返回 321给定 x = -123,返回 -321解题:直接反转,越界处理好炒蛋Java程序:public class Solution { /** * @pa...

  • lintcode:合并两个排序链表

    时间:2023-11-26 10:07:52

    题目:合并两个排序链表将两个排序链表合并为一个新的排序链表 样例给出 1->3->8->11->15->null,2->null,返回 1->2->3->8->11->15->null。解题:数据结构中的书上说过,可解,异步的方...

  • [LintCode] Find the Missing Number 寻找丢失的数字

    时间:2023-11-19 13:05:32

    Given an array contains N numbers of 0 .. N, find which number doesn't exist in the array.ExampleGiven N = 3 and the array [0, 1, 3], return 2.Challen...

  • Lintcode 175 Invert Binary Tree

    时间:2023-11-19 10:06:29

    I did it in a recursive way. There is another iterative way to do it. I will come back at it later./** * Definition of TreeNode: * public class TreeNo...

  • Lintcode: Segment Tree Query

    时间:2023-11-16 15:27:01

    For an integer array (index from 0 to n-1, where n is the size of this array), in the corresponding SegmentTree, each node stores an extra attribute m...

  • [LintCode] Maximal Square 最大正方形

    时间:2023-11-14 15:14:42

    Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.Have you met this question in a real ...

  • [LintCode] Paint House 粉刷房子

    时间:2023-11-12 16:09:23

    There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certai...

  • [LintCode] Longest Common Prefix 最长共同前缀

    时间:2023-10-20 20:00:02

    Given k strings, find the longest common prefix (LCP).Have you met this question in a real interview?ExampleFor strings "ABCD", "ABEF" and "ACEF", the...