04 2016 档案

摘要:Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, 阅读全文
posted @ 2016-04-30 21:30 YuriFLAG 阅读(122) 评论(0) 推荐(0)
摘要:Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such th 阅读全文
posted @ 2016-04-30 20:47 YuriFLAG 阅读(183) 评论(0) 推荐(0)
摘要:Given an directed graph, a topological order of the graph nodes is defined as follow: For each directed edge A -> B in graph, A must before B in the o 阅读全文
posted @ 2016-04-29 16:36 YuriFLAG 阅读(191) 评论(0) 推荐(0)
摘要:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization: Nodes are labeled 阅读全文
posted @ 2016-04-29 15:22 YuriFLAG 阅读(191) 评论(0) 推荐(0)
摘要:Given an integer array with no duplicates. A max tree building on this array is defined as follow: The root is the maximum number in the array The lef 阅读全文
posted @ 2016-04-29 08:52 YuriFLAG 阅读(226) 评论(0) 推荐(0)
摘要:Given preorder and inorder traversal of a tree, construct the binary tree. 阅读全文
posted @ 2016-04-28 09:40 YuriFLAG 阅读(124) 评论(0) 推荐(0)
摘要:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. 阅读全文
posted @ 2016-04-27 08:43 YuriFLAG 阅读(172) 评论(0) 推荐(0)
摘要:Given a unsorted array with integers, find the median of it. A median is the middle number of the array after it is sorted. If there are even numbers 阅读全文
posted @ 2016-04-26 20:11 YuriFLAG 阅读(305) 评论(0) 推荐(0)
摘要:There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh 阅读全文
posted @ 2016-04-26 09:08 YuriFLAG 阅读(129) 评论(0) 推荐(0)
摘要: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 阅读(131) 评论(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 阅读(117) 评论(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 阅读(123) 评论(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 阅读(168) 评论(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 阅读(139) 评论(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 阅读(128) 评论(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 阅读(173) 评论(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 阅读(184) 评论(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 阅读(291) 评论(0) 推荐(0)
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single 阅读全文
posted @ 2016-04-15 09:22 YuriFLAG 阅读(138) 评论(0) 推荐(0)
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single 阅读全文
posted @ 2016-04-15 09:22 YuriFLAG 阅读(161) 评论(0) 推荐(0)
摘要:Given a sorted array of n integers, find the starting and ending position of a given target value. If the target is not found in the array, return [-1 阅读全文
posted @ 2016-04-09 09:14 YuriFLAG 阅读(129) 评论(0) 推荐(0)
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2016-04-09 09:03 YuriFLAG 阅读(135) 评论(0) 推荐(0)
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For exampl 阅读全文
posted @ 2016-04-08 09:43 YuriFLAG 阅读(155) 评论(0) 推荐(0)
摘要:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist 阅读全文
posted @ 2016-04-07 10:05 YuriFLAG 阅读(159) 评论(0) 推荐(0)
摘要:Given a list of words and an integer k, return the top k frequent words in the list. You should order the words by the frequency of them in the return 阅读全文
posted @ 2016-04-06 11:18 YuriFLAG 阅读(620) 评论(0) 推荐(0)
摘要:Write a program to check whether a given number is an ugly number`. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For ex 阅读全文
posted @ 2016-04-06 09:48 YuriFLAG 阅读(171) 评论(0) 推荐(0)
摘要:Given k sorted integer arrays, merge them into one sorted array. Challenge Do it in O(N log k). N is the total number of integers. k is the number of 阅读全文
posted @ 2016-04-05 16:28 YuriFLAG 阅读(361) 评论(0) 推荐(0)
摘要:Write a method anagram(s,t) to decide if two strings are anagrams or not. Example Given s="abcd", t="dcab", return true. 根据定义可知,两个字符串为anagrams,则每个字符出现 阅读全文
posted @ 2016-04-04 21:30 YuriFLAG 阅读(226) 评论(0) 推荐(0)
摘要:Given an array of integers, find two non-overlapping subarrays which have the largest sum. The number in each subarray should be contiguous. Return th 阅读全文
posted @ 2016-04-02 11:33 YuriFLAG 阅读(210) 评论(0) 推荐(0)
摘要:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic 阅读全文
posted @ 2016-04-02 10:31 YuriFLAG 阅读(151) 评论(0) 推荐(0)
摘要:Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文
posted @ 2016-04-02 09:39 YuriFLAG 阅读(159) 评论(0) 推荐(0)
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2016-04-02 09:09 YuriFLAG 阅读(134) 评论(0) 推荐(0)
摘要:Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime 阅读全文
posted @ 2016-04-02 09:03 YuriFLAG 阅读(140) 评论(0) 推荐(0)