
算法题
文章平均质量分 80
angelina525
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
微软面试题——把二元查找树转变成排序的双向链表
题目:输入一棵二元查找树,将该二元查找树转换成一个排序的双向链表。要求不能创建任何新的节点,只调整指针的指向。 解题原理:节点10的左指针应该指向其左子树值最大的节点8,节点8的右指针应该指向节点10,节点10的右指针应该指向其右子树的最小节点12,节点12的左指针应该指向节点10。因此采用需找pCurrent节点左子树的最大节点leftMaxNode,其右子树的最小节点ri原创 2013-09-07 22:23:38 · 665 阅读 · 0 评论 -
leetcode之Reorder List
problem:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, re原创 2013-11-13 17:02:08 · 710 阅读 · 0 评论 -
leetcode之Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet"原创 2013-11-13 22:49:20 · 838 阅读 · 0 评论 -
leetcode之LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if原创 2013-11-13 17:55:59 · 934 阅读 · 0 评论 -
leetcode之Insertion Sort List
Sort a linked list using insertion sort.此题较简单,就是练习链表增删查问题class Solution {public: ListNode *insertionSortList(ListNode *head) { // IMPORTANT: Please reset any member data you declared,原创 2013-11-13 21:27:10 · 753 阅读 · 0 评论 -
LeetCode之Best Time to Buy and Sell Stock III
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You原创 2013-05-16 16:48:58 · 626 阅读 · 0 评论 -
LeetCode之Surrounded Regions
Surrounded RegionsFeb 222901 / 10932Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surro原创 2013-05-14 09:28:13 · 552 阅读 · 0 评论