01 2018 档案

Insert Interval
摘要:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initia 阅读全文

posted @ 2018-01-23 13:00 夜的第八章 阅读(143) 评论(2) 推荐(0)

candy(贪心)
摘要:【题目】 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 followi 阅读全文

posted @ 2018-01-23 10:50 夜的第八章 阅读(255) 评论(0) 推荐(0)

Best Time to Buy and Sell Stock
摘要: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 @ 2018-01-22 18:21 夜的第八章 阅读(147) 评论(0) 推荐(0)

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 comple 阅读全文

posted @ 2018-01-22 18:15 夜的第八章 阅读(145) 评论(0) 推荐(0)

distinct subsequences
摘要:Given a string S and a string T, count the number of distinct subsequences of S which equals T. A subsequence of a string is a new string which is for 阅读全文

posted @ 2018-01-22 15:53 夜的第八章 阅读(133) 评论(0) 推荐(0)

edit distance(编辑距离,两个字符串之间相似性的问题)
摘要:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have 阅读全文

posted @ 2018-01-21 16:04 夜的第八章 阅读(173) 评论(0) 推荐(0)

trapping rain water
摘要:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. 阅读全文

posted @ 2018-01-21 11:45 夜的第八章 阅读(149) 评论(0) 推荐(0)

word break II(单词切分)
摘要:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is 阅读全文

posted @ 2018-01-20 16:54 夜的第八章 阅读(191) 评论(0) 推荐(0)

sudoku solver(数独)
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character '.'. You may assume that there will be 阅读全文

posted @ 2018-01-20 11:28 夜的第八章 阅读(197) 评论(0) 推荐(0)

N-Queens(N皇后问题)
摘要:题目: The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return 阅读全文

posted @ 2018-01-19 21:17 夜的第八章 阅读(207) 评论(0) 推荐(0)

jump game II
摘要: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 @ 2018-01-19 16:06 夜的第八章 阅读(160) 评论(0) 推荐(0)

小题目(错题)
摘要:1、 public class StringDemo{ private static final String MESSAGE="taobao"; public static void main(String [] args) { String a ="tao"+"bao"; String b="t 阅读全文

posted @ 2018-01-18 21:53 夜的第八章 阅读(243) 评论(0) 推荐(0)

星际穿越(网易)
摘要:题目描述 航天飞行器是一项复杂而又精密的仪器,飞行器的损耗主要集中在发射和降落的过程,科学家根据实验数据估计,如果在发射过程中,产生了 x 程度的损耗,那么在降落的过程中就会产生 x2 程度的损耗,如果飞船的总损耗超过了它的耐久度,飞行器就会爆炸坠毁。问一艘耐久度为 h 的飞行器,假设在飞行过程中不 阅读全文

posted @ 2018-01-18 21:34 夜的第八章 阅读(114) 评论(0) 推荐(0)

sort list(给链表排序)
摘要:Sort a linked list in O(n log n) time using constant space complexity. 题目要求使用O(nlogn)时间复杂度,可以考虑使用归并排序,在 merge two sorted lists 中,已经知道了将两个有序链表进行合并。这里只要 阅读全文

posted @ 2018-01-18 10:59 夜的第八章 阅读(359) 评论(0) 推荐(0)

reorder list(链表重新排序)
摘要: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 阅读全文

posted @ 2018-01-17 16:32 夜的第八章 阅读(167) 评论(0) 推荐(0)

数据流中的中位数
摘要:如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序之后位于中间的数值。如果从数据流中读出偶数个数值,那么中位数就是所有数值排序之后中间两个数的平均值。 分析: 中位数就是数据排序前一部分的最后一个(最大值)和后半部分的第一个(最小值)的平均。当元素个数为奇数个时可 阅读全文

posted @ 2018-01-17 14:52 夜的第八章 阅读(287) 评论(2) 推荐(1)

insertion sort list (使用插入排序给链表排序)
摘要:Sort a linked list using insertion sort. 对于数组的插入排序,可以参看排序算法入门之插入排序(java实现),遍历每个元素,然后相当于把每个元素插入到前面已经排好序的数组里,对于数组,只要当前元素比前一个元素小,则前一个元素后移,然后继续跟再前面的元素比。 对 阅读全文

posted @ 2018-01-17 12:57 夜的第八章 阅读(328) 评论(0) 推荐(0)

Copy List with Random Pointer(复杂链表复制)
摘要:输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head。(注意,输出结果中请不要返回参数中的节点引用,否则判题程序会直接返回空) 第一种方法:使用map存放原节点和其复制节点。然后再给复制节点的next/rando 阅读全文

posted @ 2018-01-17 10:40 夜的第八章 阅读(145) 评论(0) 推荐(0)

二维数组中查找
摘要:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 由题目知,可以对每一行使用二分查找。但是这样并没有完全利用题目所给的条件。 阅读全文

posted @ 2018-01-16 14:59 夜的第八章 阅读(126) 评论(0) 推荐(0)

gas station
摘要:Gas Station 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 阅读全文

posted @ 2018-01-15 18:51 夜的第八章 阅读(214) 评论(0) 推荐(0)

回文序列(网易)
摘要:题目描述 如果一个数字序列逆置之后跟原序列是一样的就称这样的数字序列为回文序列。例如:{1, 2, 1}, {15, 78, 78, 15} , {112} 是回文序列, {1, 2, 2}, {15, 78, 87, 51} ,{112, 2, 11} 不是回文序列。现在给出一个数字序列,允许使用 阅读全文

posted @ 2018-01-12 16:55 夜的第八章 阅读(302) 评论(0) 推荐(0)

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 e 阅读全文

posted @ 2018-01-12 16:15 夜的第八章 阅读(219) 评论(0) 推荐(0)

Sum Root to Leaf Numbers
摘要:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 whic 阅读全文

posted @ 2018-01-12 13:08 夜的第八章 阅读(103) 评论(0) 推荐(0)

Evaluate Reverse Polish Notation
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e 阅读全文

posted @ 2018-01-12 10:23 夜的第八章 阅读(117) 评论(0) 推荐(0)

Palindrome Partitioning
摘要: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 @ 2018-01-11 16:18 夜的第八章 阅读(114) 评论(0) 推荐(0)

triangle
摘要: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 @ 2018-01-11 14:58 夜的第八章 阅读(158) 评论(0) 推荐(0)

Populating Next Right Pointers in Each Node(I and II)
摘要:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its ne 阅读全文

posted @ 2018-01-11 10:10 夜的第八章 阅读(106) 评论(0) 推荐(0)

分苹果(网易)
摘要:题目描述 n 只奶牛坐在一排,每个奶牛拥有 ai 个苹果,现在你要在它们之间转移苹果,使得最后所有奶牛拥有的苹果数都相同,每一次,你只能从一只奶牛身上拿走恰好两个苹果到另一个奶牛上,问最少需要移动多少次可以平分苹果,如果方案不存在输出 -1。 输入描述: 每个输入包含一个测试用例。每个测试用例的第一 阅读全文

posted @ 2018-01-10 19:52 夜的第八章 阅读(186) 评论(0) 推荐(0)

Flatten Binary Tree to Linked List
摘要:Given a binary tree, flatten it to a linked list in-place. For example,Given The flattened tree should look like: Hints: If you notice carefully in th 阅读全文

posted @ 2018-01-10 17:13 夜的第八章 阅读(116) 评论(0) 推荐(0)

Construct Binary Tree from Inorder and Postorder Traversal(根据中序遍历和后序遍历构建二叉树)
摘要:根据中序和后续遍历构建二叉树。 阅读全文

posted @ 2018-01-10 15:28 夜的第八章 阅读(107) 评论(0) 推荐(0)

Construct Binary Tree from Preorder and Inorder Traversal(根据前序中序构建二叉树)
摘要:根据前序中序构建二叉树。 参考:https://www.cnblogs.com/springfor/p/3884034.html 阅读全文

posted @ 2018-01-10 12:12 夜的第八章 阅读(145) 评论(3) 推荐(0)

Validate Binary Search Tree(一定掌握的方法)
摘要:Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only 阅读全文

posted @ 2018-01-10 10:53 夜的第八章 阅读(159) 评论(0) 推荐(0)

path sum II(深度优先的递归实现掌握)
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Given the below binary tree and sum 阅读全文

posted @ 2018-01-09 20:34 夜的第八章 阅读(150) 评论(0) 推荐(0)

convert sorted list to binary search tree(将有序链表转成平衡二叉搜索树)
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced bina 阅读全文

posted @ 2018-01-09 19:26 夜的第八章 阅读(217) 评论(0) 推荐(0)

Binary Tree Zigzag Level Order Traversal(z字形打印二叉树)
摘要:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文

posted @ 2018-01-09 11:25 夜的第八章 阅读(249) 评论(0) 推荐(0)

java虚拟机的类加载机制
摘要:引言 我们写的代码是放在.java文件中,经过编译器编译后,转成.class文件。Class文件是一串二进制流,它可以被各平台的虚拟机所接受,实现跨平台。 虚拟机将描述类的数据从class文件加载到内存,并对数据进行校验、解析、初始化,最终形成可以被虚拟机直接使用的Java类型,这就是虚拟机的类加载 阅读全文

posted @ 2018-01-08 21:52 夜的第八章 阅读(209) 评论(5) 推荐(1)

unique-binary-search-trees II
摘要: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 @ 2018-01-08 16:42 夜的第八章 阅读(137) 评论(0) 推荐(0)

unique-binary-search-trees
摘要:unique-binary-search-trees 题目: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, the 阅读全文

posted @ 2018-01-08 15:42 夜的第八章 阅读(240) 评论(0) 推荐(0)

二叉树的先序中序后续遍历(递归非递归)
摘要:转载:http://blog.csdn.net/jssongwei/article/details/50790253 首先来看一棵二叉树: 1、前序遍历: 前序遍历首先访问根结点然后遍历左子树,最后遍历右子树。在遍历左、右子树时,仍然先访问根结点,然后遍历左子树,最后遍历右子树。 若二叉树为空则结束 阅读全文

posted @ 2018-01-08 14:27 夜的第八章 阅读(1140) 评论(0) 推荐(0)

reverse Linked List II
摘要:Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2- 阅读全文

posted @ 2018-01-08 11:00 夜的第八章 阅读(226) 评论(0) 推荐(0)

decode ways(动态规划)
摘要: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 @ 2018-01-07 17:48 夜的第八章 阅读(136) 评论(0) 推荐(0)

word search(二维数组中查找单词(匹配字符串))
摘要: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, where "adjac 阅读全文

posted @ 2018-01-07 15:07 夜的第八章 阅读(4450) 评论(0) 推荐(0)

下厨房(网易)
摘要:题目描述 牛牛想尝试一些新的料理,每个料理需要一些不同的材料,问完成所有的料理需要准备多少种不同的材料。 输入描述: 每个输入包含 1 个测试用例。每个测试用例的第 i 行,表示完成第 i 件料理需要哪些材料,各个材料用空格隔开,输入只包含大写英文字母和空格,输入文件不超过 50 行,每一行不超过 阅读全文

posted @ 2018-01-06 22:09 夜的第八章 阅读(2073) 评论(0) 推荐(0)

数字翻转
摘要:题目描述 对于一个整数X,定义操作rev(X)为将X按数位翻转过来,并且去除掉前导0。例如:如果 X = 123,则rev(X) = 321;如果 X = 100,则rev(X) = 1.现在给出整数x和y,要求rev(rev(x) + rev(y))为多少? 输入描述: 输入为一行,x、y(1 ≤ 阅读全文

posted @ 2018-01-06 22:07 夜的第八章 阅读(305) 评论(0) 推荐(0)

春招秋招准备
摘要:参考: 作者:小新没有蜡笔~链接:https://www.nowcoder.com/discuss/61438?type=0&order=0&pos=9&page=0来源:牛客网 1、看集合框架的底层实现原理。2、数据结构与算法分析。3、深入理解Java虚拟机。4、effective Java 。5 阅读全文

posted @ 2018-01-06 16:36 夜的第八章 阅读(192) 评论(0) 推荐(0)

Remove Duplicates from Sorted List II
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given 1->2 阅读全文

posted @ 2018-01-06 15:57 夜的第八章 阅读(139) 评论(0) 推荐(0)

partition List(划分链表)
摘要: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 should preserve the 阅读全文

posted @ 2018-01-06 14:50 夜的第八章 阅读(347) 评论(0) 推荐(0)

search in rotated sorted array II
摘要:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose an arra 阅读全文

posted @ 2018-01-06 14:20 夜的第八章 阅读(190) 评论(0) 推荐(0)

search a 2D matrix(在二维数组中搜索一个元素)
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f 阅读全文

posted @ 2018-01-06 10:55 夜的第八章 阅读(162) 评论(0) 推荐(0)

rotate list
摘要:Given a list, rotate the list to the right by k places, where k is non-negative. Example: 题目是要求从后往前的第k个节点旋转。这里的4.我们要做的就是:1、将一个指针移到最后节点。2、将另一个指针移到旋转点的前 阅读全文

posted @ 2018-01-06 10:14 夜的第八章 阅读(123) 评论(0) 推荐(0)

Set Matrix Zeroes
摘要:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra sp 阅读全文

posted @ 2018-01-05 20:28 夜的第八章 阅读(168) 评论(0) 推荐(0)

Remove Duplicates from Sorted Array II
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For example,Given sorted array nums = [1,1,1,2,2,3], Your function sho 阅读全文

posted @ 2018-01-05 18:47 夜的第八章 阅读(120) 评论(0) 推荐(0)

spiral matrix II
摘要: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 followi 阅读全文

posted @ 2018-01-05 16:02 夜的第八章 阅读(125) 评论(0) 推荐(0)

merge intervals(合并间隔)
摘要:Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18]. 题目没有说所有间隔的 阅读全文

posted @ 2018-01-05 15:16 夜的第八章 阅读(234) 评论(0) 推荐(0)

jump game
摘要: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 @ 2018-01-04 19:32 夜的第八章 阅读(153) 评论(0) 推荐(0)

spiral matrix 螺旋矩阵
摘要: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: You s 阅读全文

posted @ 2018-01-04 16:56 夜的第八章 阅读(316) 评论(0) 推荐(0)

pow(x,n)
摘要:Implement pow(x, n). Example 1: Example 2: 实现x^n。这里要注意的是n为负数的情况。n为负数时也可以将n转成正数,这样x=1/x。。代码用了另一种方法,见代码。 阅读全文

posted @ 2018-01-03 19:13 夜的第八章 阅读(157) 评论(0) 推荐(0)

minimun path sum(最小路径和)
摘要: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 @ 2018-01-03 15:43 夜的第八章 阅读(256) 评论(0) 推荐(0)

unique paths II
摘要:Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space 阅读全文

posted @ 2018-01-03 14:58 夜的第八章 阅读(133) 评论(0) 推荐(0)

combination sum、permutation、subset(组合和、全排列、子集)
摘要:combination sum I、permutation I、subsets I 是组合和、全排列、子集的第一种情况,给定数组中没有重复的元素。 combination sum II、permutation II、subsets II 是组合和、全排列、子集的第而种情况,给定数组中有重复元素。 c 阅读全文

posted @ 2018-01-03 12:56 夜的第八章 阅读(462) 评论(0) 推荐(0)

subsets II
摘要:Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not conta 阅读全文

posted @ 2018-01-03 12:22 夜的第八章 阅读(132) 评论(0) 推荐(0)

subsets(子集)
摘要:Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. For ex 阅读全文

posted @ 2018-01-03 11:01 夜的第八章 阅读(170) 评论(0) 推荐(0)

combinations(组合)
摘要:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example,If n = 4 and k = 2, a solution is: 从1,。。。,n中选出k个 阅读全文

posted @ 2018-01-02 21:59 夜的第八章 阅读(197) 评论(0) 推荐(0)

Group Anagrams 群组错位词
摘要:Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: Note: All inputs will be i 阅读全文

posted @ 2018-01-02 21:27 夜的第八章 阅读(161) 评论(0) 推荐(0)

rotate image(旋转数组)
摘要:You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note:You have to rotate the image in-place, which 阅读全文

posted @ 2018-01-02 20:28 夜的第八章 阅读(187) 评论(0) 推荐(0)

permutations II(全排列 2)
摘要:题目要求 对于其基础题PermutationsI请参考我的另一篇博客这里添加的难度在于,排列组合的数字中可能存在重复。这就需要想方法,将结果集中重复的结果删去。而这里,我参考了另一名答题者的答案,在试图将数字添入结果集中时,就判断会不会产生重复的结果,从而使避免重复。 PermutationsI也可 阅读全文

posted @ 2018-01-02 19:46 夜的第八章 阅读(1207) 评论(0) 推荐(0)

multiply Strings
摘要:参考:https://www.cnblogs.com/TenosDoIt/p/3735309.html Given two numbers represented as strings, return multiplication of the numbers as a string. Note: 阅读全文

posted @ 2018-01-02 16:31 夜的第八章 阅读(122) 评论(0) 推荐(0)

导航