关闭

leetcode 217/219/220 contains duplicate 1,2,3

217   Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every e...
阅读(19) 评论(0)

leetcode 310. Minimum Height Trees

For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called mini...
阅读(27) 评论(0)

c/c++ 链接、链接器

链接 链接:将各种代码和数据片段收集并组合成为一个单一文件的过程,这个文件可被加载(复制)到内存中。 编译器作用:  .c -> .i -> .s -> .o 可重定位目标文件(.o): 包含二进制代码和数据,可和其他可重定位目标文件合成 可执行文件。 可重定位目标模块里面有一个符号表,包含定义和引用的符号的信息 ...
阅读(9) 评论(0)

leetcode 547. Friend Circles

There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, the...
阅读(23) 评论(0)

leetcode 128. Longest Consecutive Sequence

Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence i...
阅读(16) 评论(0)

leetcode MYSQL数据库题目

175. Combine Two Tables Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId | int | | FirstName | varchar | | LastName | varchar |...
阅读(28) 评论(0)

Redis简易教程

Redis 简介 Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库。 Redis 与其他 key - value 缓存产品有以下三个特点: Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可以再次加载进行使用。 Redis不仅仅支持简单的key-value类型的数据,同时还提供list,set,zse...
阅读(36) 评论(0)

leetcode 124. Binary Tree Maximum Path Sum

Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The...
阅读(17) 评论(0)

leetcode 129. Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the tota...
阅读(21) 评论(0)

leetcode 116/117 Populating Next Right Pointers in Each Node 1/2

116 and 117 同一份代码: 无论什么二叉树,都可以。不一定是完全二叉树  Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next po...
阅读(19) 评论(0)

leetcode 114. Flatten Binary Tree to Linked List

Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 一次基本操作:root为1,56移动到4下面,2移动到原本5的位置。root变为2...
阅读(14) 评论(0)

leetcode 112/113. Path Sum 1/II

112: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tre...
阅读(23) 评论(0)

leetcode 110. Balanced Binary Tree

Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe...
阅读(18) 评论(0)

leetcode 109. Convert Sorted List to Binary Search Tree

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. /** * Definition for singly-linked list. * struct ListNode { * int val;...
阅读(18) 评论(0)

leetcode 108. Convert Sorted Array to Binary Search Tree

形成一个BST 由于已经是排序后的数组,所以直接找到下标中间点就行。 如果没有排序的情况,应该先排序。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode...
阅读(19) 评论(0)

leetcode 106. Construct Binary Tree from Inorder and Postorder Traversal

Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. 后序遍历的最后一个是根节点,将中序遍历分开成左右子树。 /** * Definition for a...
阅读(19) 评论(0)

leetcode 105. Construct Binary Tree from Preorder and Inorder Traversal

Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. /** * Definition for a binary tree node. * stru...
阅读(18) 评论(0)

leetcode 104. Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 递归 /** * Definition for ...
阅读(28) 评论(0)

leetcode 100. Same Tree

Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. /** ...
阅读(24) 评论(0)

leetcode 99. Recover Binary Search Tree

Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note: A solution using O(n) space is pretty straight forward.  中序遍历二叉树,出现的节点的值...
阅读(27) 评论(0)
37条 共2页1 2 下一页 尾页
    个人资料
    • 访问:947次
    • 积分:371
    • 等级:
    • 排名:千里之外
    • 原创:11篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档