
leetcode tutorial
java_student09
这个作者很懒,什么都没留下…
展开
-
Reverse Words in a String
题目描述Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".原创 2014-05-13 08:41:52 · 1555 阅读 · 0 评论 -
Binary Tree Level Order Traversal II
题目描述 Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).原创 2015-06-07 21:04:32 · 2641 阅读 · 0 评论 -
leetcode_PermutationSequence
题目描述(Permutation Sequence) The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n =原创 2015-06-05 21:31:36 · 2815 阅读 · 0 评论 -
leetcode_Design and implement a data structure for Least Recently Used (LRU) cache
public class LRUCache { private Map map = null; private int capacity; private int size; public LRUCache(int capacity) { this.capacity = capacity; size = 0; map = new LinkedHashM原创 2014-05-13 10:28:01 · 2410 阅读 · 0 评论 -
path_sum2
题目描述 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 = 22, 5 / \原创 2015-06-06 10:57:31 · 2624 阅读 · 0 评论 -
path_sum
题目描述 Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary t原创 2015-06-06 10:36:47 · 2654 阅读 · 0 评论 -
leetcode_single number
题目描述 Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without原创 2015-05-28 22:19:04 · 2632 阅读 · 0 评论 -
leetcode_wordladder2
题目描述 Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: Only one letter can be changed at a time原创 2015-05-26 20:06:56 · 2795 阅读 · 0 评论 -
leetcode_wordladder
题目描述 Given two words (beginWord and endWord), and a dictionary, find the length of shortest transformation sequence from beginWord to endWord, such that: Only one letter can be changed at a time原创 2015-05-26 17:42:38 · 2737 阅读 · 0 评论 -
leetcode_Validate Binary Search Tree
题目描述 Given a binary tree, determine if it is a valid binary search tree (BST).原创 2015-05-27 19:10:43 · 2758 阅读 · 0 评论 -
leetcode_Max Points on a Line
/* * Max Points on a Line * */ public int maxPoints(Point[] points) { int max = 0; for(int i=0;i<points.length-1;i++) { for(int j=i+1;j<points.length;j++)原创 2014-05-13 10:27:12 · 1492 阅读 · 0 评论 -
leetcode_Evaluate Reverse Polish Notation
/* * Evaluate Reverse Polish Notation * */ public int evalRPN(String[] tokens) { int result = 0; Stack mStack = new Stack<>(); for(String mString:tokens) {原创 2014-05-13 10:26:51 · 1397 阅读 · 0 评论 -
leetcode_Sort a linked list using insertion sort.
/* * Sort a linked list using insertion sort. * */ public ListNode insertionSortList(ListNode head) { ListNode p = new ListNode(0); ListNode phead = p; while(head!=null)原创 2014-05-13 10:27:39 · 1834 阅读 · 0 评论 -
leetcode_Sort a linked list in O(n log n) time using constant space complexity.
/* * Sort a linked list in O(n log n) time using constant space complexity. * */ public ListNode sortList(ListNode head) { ListNode start1 = null; ListNode result = null; ListNode start3 =原创 2014-05-13 10:27:25 · 1771 阅读 · 0 评论 -
leetcode_BinaryTreeLevelOrderTraversal
题目描述 Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9原创 2015-06-07 20:50:28 · 3009 阅读 · 0 评论