10 2016 档案

摘要:Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is b 阅读全文
posted @ 2016-10-31 07:34 微微程序媛 阅读(757) 评论(0) 推荐(0)
摘要:Shuffle a set of numbers without duplicates. Example: 阅读全文
posted @ 2016-10-31 06:07 微微程序媛 阅读(288) 评论(0) 推荐(0)
摘要: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 comple 阅读全文
posted @ 2016-10-31 05:08 微微程序媛 阅读(202) 评论(0) 推荐(0)
摘要: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 comple 阅读全文
posted @ 2016-10-31 04:09 微微程序媛 阅读(111) 评论(0) 推荐(0)
摘要: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 comple 阅读全文
posted @ 2016-10-31 04:08 微微程序媛 阅读(156) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2016-10-31 04:08 微微程序媛 阅读(113) 评论(0) 推荐(0)
摘要:Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the game. The snak 阅读全文
posted @ 2016-10-30 14:47 微微程序媛 阅读(222) 评论(0) 推荐(0)
摘要:Given a snake and ladder board, find the minimum number of dice throws required to reach the destination or last cell from source or 1st cell. Basical 阅读全文
posted @ 2016-10-30 13:19 微微程序媛 阅读(849) 评论(0) 推荐(0)
摘要:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then l 阅读全文
posted @ 2016-10-30 05:27 微微程序媛 阅读(124) 评论(0) 推荐(0)
摘要:Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as 2->1->4->3. Your a 阅读全文
posted @ 2016-10-30 04:06 微微程序媛 阅读(94) 评论(0) 推荐(0)
摘要:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 归并排序o(nlgk); 法二 : 优先队列 维护一个长为n的队列 o(n *lgk) 阅读全文
posted @ 2016-10-30 02:59 微微程序媛 阅读(133) 评论(0) 推荐(0)
摘要:Sort a linked list in O(n log n) time using constant space complexity. 双链表用快排 单链表用归并 阅读全文
posted @ 2016-10-29 04:17 微微程序媛 阅读(176) 评论(0) 推荐(0)
摘要:Sort a linked list using insertion sort. 复杂度 o(n^2); 插入排序 (Insertion Sort) 设有一组关键字{K1, K2,…, Kn};排序开始就认为 K1 是一个有序序列;让 K2 插入上述表长为 1 的有序序列,使之成为一个表长为 2 的 阅读全文
posted @ 2016-10-29 03:41 微微程序媛 阅读(111) 评论(0) 推荐(0)
摘要:Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j]and the d 阅读全文
posted @ 2016-10-26 08:37 微微程序媛 阅读(159) 评论(0) 推荐(0)
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2016-10-26 06:45 微微程序媛 阅读(100) 评论(0) 推荐(0)
摘要:Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical a 阅读全文
posted @ 2016-10-26 05:47 微微程序媛 阅读(131) 评论(0) 推荐(0)
摘要:import java.util.*; class Node{ String val; Set children = new HashSet(); // at most 15 children; public Node(String val){ this.val = val; this.children = new HashSet(); ... 阅读全文
posted @ 2016-10-26 04:01 微微程序媛 阅读(271) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-10-26 03:57 微微程序媛 阅读(564) 评论(0) 推荐(0)
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文
posted @ 2016-10-26 00:42 微微程序媛 阅读(157) 评论(0) 推荐(0)
摘要:You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you nee 阅读全文
posted @ 2016-10-26 00:20 微微程序媛 阅读(127) 评论(0) 推荐(0)
摘要:Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 阅读全文
posted @ 2016-10-24 07:36 微微程序媛 阅读(147) 评论(0) 推荐(0)
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: Given an encoded message containing digits, determine t 阅读全文
posted @ 2016-10-24 05:29 微微程序媛 阅读(147) 评论(0) 推荐(0)
摘要:We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wron 阅读全文
posted @ 2016-10-24 04:48 微微程序媛 阅读(173) 评论(0) 推荐(0)
摘要:Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true Note: It is intended for the 阅读全文
posted @ 2016-10-17 14:06 微微程序媛 阅读(207) 评论(0) 推荐(0)
摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: Pan 阅读全文
posted @ 2016-10-16 13:55 微微程序媛 阅读(126) 评论(0) 推荐(0)
摘要:118. Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return 阅读全文
posted @ 2016-10-16 13:53 微微程序媛 阅读(136) 评论(0) 推荐(0)
摘要:Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner as s 阅读全文
posted @ 2016-10-16 12:49 微微程序媛 阅读(160) 评论(0) 推荐(0)
摘要:A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Find all strobogrammatic numbers that are o 阅读全文
posted @ 2016-10-16 08:12 微微程序媛 阅读(186) 评论(0) 推荐(0)
摘要:A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to determine if a number i 阅读全文
posted @ 2016-10-16 08:11 微微程序媛 阅读(147) 评论(0) 推荐(0)
摘要:Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This 阅读全文
posted @ 2016-10-16 06:09 微微程序媛 阅读(208) 评论(0) 推荐(1)
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2016-10-14 01:49 微微程序媛 阅读(133) 评论(0) 推荐(0)
摘要:There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following re 阅读全文
posted @ 2016-10-14 01:47 微微程序媛 阅读(164) 评论(0) 推荐(0)
摘要:There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it cost 阅读全文
posted @ 2016-10-14 00:11 微微程序媛 阅读(317) 评论(0) 推荐(0)
摘要:The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each hou 阅读全文
posted @ 2016-10-13 09:30 微微程序媛 阅读(178) 评论(0) 推荐(0)
摘要:Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. Hide Company 阅读全文
posted @ 2016-10-13 08:16 微微程序媛 阅读(128) 评论(0) 推荐(0)
摘要:Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target. Note: Given target value is a floati 阅读全文
posted @ 2016-10-13 06:42 微微程序媛 阅读(151) 评论(0) 推荐(0)
摘要:Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target. Note: Given target value is a floati 阅读全文
posted @ 2016-10-13 06:11 微微程序媛 阅读(124) 评论(0) 推荐(0)
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l 阅读全文
posted @ 2016-10-12 12:24 微微程序媛 阅读(104) 评论(0) 推荐(0)
摘要:Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l 阅读全文
posted @ 2016-10-12 12:06 微微程序媛 阅读(110) 评论(0) 推荐(0)
摘要:Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 1 阅读全文
posted @ 2016-10-12 11:53 微微程序媛 阅读(129) 评论(0) 推荐(0)
摘要:Given a binary tree, count the number of uni-value subtrees. A Uni-value subtree means all nodes of the subtree have the same value. For example:Given 阅读全文
posted @ 2016-10-12 11:52 微微程序媛 阅读(130) 评论(0) 推荐(0)
摘要:Given a binary tree, find the length of the longest consecutive sequence path. The path refers to any sequence of nodes from some starting node to any 阅读全文
posted @ 2016-10-12 10:22 微微程序媛 阅读(140) 评论(0) 推荐(0)
摘要:Given a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 \ 4 阅读全文
posted @ 2016-10-12 05:49 微微程序媛 阅读(112) 评论(0) 推荐(0)
摘要:Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree. You may assume each number in the seq 阅读全文
posted @ 2016-10-12 04:17 微微程序媛 阅读(151) 评论(0) 推荐(0)
摘要:Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in 阅读全文
posted @ 2016-10-11 08:44 微微程序媛 阅读(134) 评论(0) 推荐(0)
摘要:You are given a m x n 2D grid initialized with these three possible values. Fill each empty room with the distance to its nearest gate. If it is impos 阅读全文
posted @ 2016-10-11 08:43 微微程序媛 阅读(157) 评论(0) 推荐(0)
摘要:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen 阅读全文
posted @ 2016-10-11 08:39 微微程序媛 阅读(115) 评论(0) 推荐(0)
摘要:Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should 阅读全文
posted @ 2016-10-11 08:37 微微程序媛 阅读(135) 评论(0) 推荐(0)
摘要:Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution sti 阅读全文
posted @ 2016-10-11 08:36 微微程序媛 阅读(159) 评论(0) 推荐(0)
摘要:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its ne 阅读全文
posted @ 2016-10-11 08:34 微微程序媛 阅读(172) 评论(0) 推荐(0)
摘要:DFS : depth first search BFS: breadth first search DFS : 46. Permutations Given a collection of distinct numbers, return all possible permutations. Fo 阅读全文
posted @ 2016-10-04 03:55 微微程序媛 阅读(164) 评论(0) 推荐(0)
摘要:Binary Search 模版 四种结构 阅读全文
posted @ 2016-10-02 05:37 微微程序媛 阅读(129) 评论(0) 推荐(0)