摘要: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: 阅读全文
posted @ 2016-04-25 20:54 YuriFLAG 阅读(130) 评论(0) 推荐(0)
摘要: Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Given n = 3, You should return the follow 阅读全文
posted @ 2016-04-25 19:37 YuriFLAG 阅读(114) 评论(0) 推荐(0)
摘要: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: " 阅读全文
posted @ 2016-04-24 18:49 YuriFLAG 阅读(110) 评论(0) 推荐(0)
摘要: Given a list, rotate the list to the right by k places, where k is non-negative. Example Given 1->2->3->4->5 and k = 2, return 4->5->1->2->3. 思路:画图。 1 阅读全文
posted @ 2016-04-23 09:14 YuriFLAG 阅读(121) 评论(0) 推荐(0)
摘要: You have two every large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of 阅读全文
posted @ 2016-04-22 21:18 YuriFLAG 阅读(165) 评论(0) 推荐(0)
摘要: Given a singly linked list L: L0 → L1 → … → Ln-1 → Ln reorder it to: L0 → Ln → L1 → Ln-1 → L2 → Ln-2 → … Example Given 1->2->3->4->null, reorder it to 阅读全文
posted @ 2016-04-21 15:11 YuriFLAG 阅读(137) 评论(0) 推荐(0)
摘要: Given a linked list, remove the nth node from the end of list and return its head. Example Given linked list: 1->2->3->4->5->null, and n = 2. After re 阅读全文
posted @ 2016-04-21 08:50 YuriFLAG 阅读(124) 评论(0) 推荐(0)
摘要: Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example, Given:s1 = "aabcc",s2 = "dbbca", When s3 = "aadbbcbcac", re 阅读全文
posted @ 2016-04-18 19:43 YuriFLAG 阅读(167) 评论(0) 推荐(0)
摘要: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo 阅读全文
posted @ 2016-04-18 09:02 YuriFLAG 阅读(180) 评论(0) 推荐(0)
摘要: Given two strings, find the longest common subsequence (LCS). Your code should return the length of LCS. Example For "ABCD" and "EDCA", the LCS is "A" 阅读全文
posted @ 2016-04-18 08:27 YuriFLAG 阅读(285) 评论(0) 推荐(0)