nudt_oys的博客

欢迎访问个人网站:littleorange.site

LeetCode 307 Range Sum Query - Mutable(树状数组 || 线段树)

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. The update(i, val) function modifies nums by u...

2017-07-30 21:18:55

阅读数 630

评论数 0

LeetCode 108 Convert Sorted Array to Binary Search Tree(二分 + 递归建树)

Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 题目大意:给出一个已经排好序的数组,构建一棵二叉搜索树。 解题思路:采用二分法,递归地构建BS...

2017-07-24 21:26:23

阅读数 431

评论数 0

LeetCode 646 Maximum Length of Pair Chain(贪心)

You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can follo...

2017-07-23 13:58:20

阅读数 759

评论数 0

LeetCode 637 Average of Levels in Binary Tree(二叉树层序遍历)

Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Input: 3 / \ 9 2...

2017-07-21 19:05:21

阅读数 1055

评论数 0

LeetCode 513 Find Bottom Left Tree Value(二叉树层序遍历)

Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 / \ 1 3 Output: 1 Example 2:  Input: ...

2017-07-19 19:49:55

阅读数 241

评论数 0

LeetCode 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 / \ \ ...

2017-07-18 19:44:42

阅读数 192

评论数 0

LeetCode 232 Implement Queue using Stacks(利用栈实现队列)

Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue.pop() -- Removes the element from in fr...

2017-07-18 18:56:06

阅读数 318

评论数 0

LeetCode 225 Implement Stack using Queues(利用队列实现栈)

Implement the following operations of a stack using queues. push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack....

2017-07-18 13:21:46

阅读数 1035

评论数 0

LeetCode 319 Bulb Switcher(数学Tricks)

There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every...

2017-07-17 13:53:37

阅读数 481

评论数 0

LeetCode 198 House Robber(基础DP)

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping y...

2017-07-15 21:29:17

阅读数 577

评论数 0

LeetCode 199 Binary Tree Right Side View(二叉树层序遍历)

Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For e...

2017-07-14 22:41:47

阅读数 547

评论数 0

LeetCode 102 Binary Tree Level Order Traversal(二叉树层序遍历)

Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tre...

2017-07-13 19:51:18

阅读数 756

评论数 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-...

2017-07-12 20:04:54

阅读数 765

评论数 0

LeetCode 38 Count and Say(字符串生成)

The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221...

2017-07-08 08:47:08

阅读数 2613

评论数 1

LeetCode 98 Validate Binary Search Tree(判断二叉搜索树)

Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains o...

2017-07-05 20:14:38

阅读数 766

评论数 0

LeetCode 20 Valid Parentheses(用栈判断括号匹配)

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in ...

2017-07-04 19:42:48

阅读数 929

评论数 0

利用归并排序求逆序数

假设A[1…n]是一个有n个不同元素的数组,若i < j 且 A[i] > A[j],则对偶(i, j)称为A的一个逆序对。例如,对于数组[2, 3, 8, 6, 1],它的所有逆序对为(1, 5),(2, 5),(3, 4),(3, 5),(4, 5),共有5个逆序对,所以逆序数为5...

2017-07-03 20:47:21

阅读数 783

评论数 0

LeetCode 14 Longest Common Prefix(最长公共前缀)

Write a function to find the longest common prefix string amongst an array of strings. 题目大意:写一个函数,找出一组字符串的最长公共字串。 解题思路:以第一个字符串为参照,逐个比较第一个字符串的第i个字符和其他...

2017-07-03 19:58:54

阅读数 538

评论数 0

提示
确定要删除当前文章?
取消 删除
关闭
关闭