【094-Binary Tree Inorder Traversal(二叉树中序遍历)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a binary tree, return the inorder traversal of its nodes’ values.
题目大意 对一棵二叉树进行中序遍历。
解题思路 解法一:递归实现,解法二:迭代实现。...
分类:
编程语言 时间:
2015-08-06 08:18:21
阅读次数:
305
【098-Validate Binary Search Tree(验证二叉搜索树)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The lef...
分类:
编程语言 时间:
2015-08-06 08:17:54
阅读次数:
234
【086-Partition List(将单链表进行分区)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
You...
分类:
编程语言 时间:
2015-08-05 07:47:52
阅读次数:
177
【088-Merge Sorted Array(合并排序数组)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
Note:
You may assume that nums1...
分类:
编程语言 时间:
2015-08-05 07:46:52
阅读次数:
149
博主在学习过程中深感基础的重要,经典排序算法是数据结构与算法学习过程中重要的一环,这里对笔试面试最常涉及到的7种排序算法(包括插入排序、希尔排序、选择排序、冒泡排序、快速排序、堆排序、归并排序)进行了详解。每一种算法都有基本介绍、算法原理分析、算法代码。
插入排序
1)算法简介
插入排序(Insertion Sort)的算法描述是一种简单直观的排序算法。它的工作原理是通过构建有序序列,对...
分类:
编程语言 时间:
2015-08-04 19:17:48
阅读次数:
413
【083-Remove Duplicates from Sorted List(排序的单链表中删除重复的结点)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,...
分类:
编程语言 时间:
2015-08-04 08:15:48
阅读次数:
151
【078-Subsets(子集)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a set of distinct integers, nums, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.
The solu...
分类:
编程语言 时间:
2015-08-03 07:51:16
阅读次数:
190
【070-Climbing Stairs(爬楼梯)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct...
分类:
编程语言 时间:
2015-08-03 07:50:48
阅读次数:
177
【079-Word Search(单词搜索)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a 2D board and a word, find if the word exists in the grid.
The word can be constructed from letters of sequentially adjacent cell,...
分类:
编程语言 时间:
2015-08-03 07:49:37
阅读次数:
131