08 2015 档案
摘要:原题链接在这里:https://leetcode.com/problems/linked-list-cycle/ 题目: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it withou
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/swap-nodes-in-pairs/ 题目: Given a linked list, swap every two adjacent nodes and return its head. You must solve
阅读全文
摘要:原题链接:https://leetcode.com/problems/add-two-numbers/ 题目: You are given two linked lists representing two non-negative numbers. The digits are stored in
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/intersection-of-two-linked-lists/ 题目: Write a program to find the node at which the intersection of two singly l
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/palindrome-linked-list/ 题目: Given a singly linked list, determine if it is a palindrome. Follow up:Could you do
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/remove-nth-node-from-end-of-list/ 题目: Given a linked list, remove the nth node from the end of list and return i
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/reverse-nodes-in-k-group/ 题目: Given a linked list, reverse the nodes of a linked list k at a time and return its
阅读全文
摘要:原题链接:https://leetcode.com/problems/remove-linked-list-elements/ 题目: Remove all elements from a linked list of integers that have value val. ExampleGiv
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/reverse-linked-list-ii/ 题目: Reverse a linked list from position m to n. Do it in-place and in one-pass. For exam
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/reverse-linked-list/ 题目: Reverse a singly linked list. 题解: Iteration 方法: 生成tail = head, cur = tail, while loop 的
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/evaluate-reverse-polish-notation/ 题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation.
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/basic-calculator-ii/ 题目: Implement a basic calculator to evaluate a simple expression string. The expression str
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/basic-calculator/ 题目: Implement a basic calculator to evaluate a simple expression string. The expression string
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ 题目: Given a binary tree, return the zigzag level order traversal of it
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/binary-tree-level-order-traversal/ 题目: Given a binary tree, return the level order traversal of its nodes' value
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/ 题目: Given inorder and postorder traversal of a tree,
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ 题目: Given preorder and inorder traversal of a tree, c
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/majority-element/ 题目: Given an array of size n, find the majority element. The majority element is the element t
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/binary-tree-postorder-traversal/ 题目: Given a binary tree, return the postorder traversal of its nodes' values. F
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/binary-tree-inorder-traversal/# 题目: Given a binary tree, return the inorder traversal of its nodes' values. For
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/binary-tree-preorder-traversal/ 题目: Given a binary tree, return the preorder traversal of its nodes' values. For
阅读全文
摘要:原题链接在这里: https://leetcode.com/problems/min-stack/ 题目: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/valid-parentheses/ 题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/implement-queue-using-stacks/ 题目: Implement the following operations of a queue using stacks. push(x) -- Push el
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/implement-stack-using-queues/ 题目: Implement the following operations of a stack using queues. push(x) -- Push el
阅读全文
摘要:这是一道面试亚马逊时的题目,要求Time O(n). 我刚开始想的是算出所有的数的总product,再去除以对应位置的元素,但这种做法的问题是若该位置为0,就会报错。到网上搜了下,才知道,原来有这种做法。e.g. arr = {0,1,2,3},生成两个array: upArr = {1,arr[0...
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/multiply-strings/ 题目: Given two non-negative integers num1 and num2 represented as strings, return the product o
阅读全文
摘要:当 arr 是一个array时,写Java开始的corner case常常会写类似下面的语句:if(arr == null || arr.length == 0){ return 0;}其实这是两个条件, arr==null 和 arr.length==0 是不同的:arr.length ==...
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/add-digits/ 题目: Given a non-negative integer num, repeatedly add all its digits until the result has only one di
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/divide-two-integers/ 题目: Divide two integers without using multiplication, division and mod operator. If it is o
阅读全文
摘要:原题链接在这里: https://leetcode.com/problems/add-binary/ 题目: Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"R
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/power-of-two/ 题目: Given an integer, write a function to determine if it is a power of two. 题解: bit manipulation,
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/rectangle-area/ 题目: Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is d
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/factorial-trailing-zeroes/ 题目: Given an integer n, return the number of trailing zeroes in n!. Example 1: Exampl
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/integer-to-roman/ 题目: Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. For exa
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/roman-to-integer/ 题目: Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. For exa
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/excel-sheet-column-number/ 题目: Given a column title as appear in an Excel sheet, return its corresponding column
阅读全文
摘要:原题链接在这里: https://leetcode.com/problems/excel-sheet-column-title/ 题目: Given a positive integer, return its corresponding column title as appear in an E
阅读全文
摘要:原题链接在这里: https://leetcode.com/problems/minimum-window-substring/ 题目: Given a string S and a string T, find the minimum window in S which will contain
阅读全文
摘要:原题链接在这里: https://leetcode.com/problems/substring-with-concatenation-of-all-words/description/ 题目: ou are given a string s and an array of strings word
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/longest-substring-without-repeating-characters/ 题目: Given a string, find the length of the longest substring wit
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/single-number/ 题目: Given an array of integers, every element appears twice except for one. Find that single one.
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/single-number-ii/ 题目: Given a non-empty array of integers, every element appears three times except for one, whi
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/3sum-closest/ 题目: Given an array S of n integers, find three integers in S such that the sum is closest to a giv
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/4sum/ 题目: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = targe
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/3sum/ 题目: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all uniq
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/fraction-to-recurring-decimal/ 题目: Given two integers representing the numerator and denominator of a fraction,
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/anagrams/ Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "
阅读全文
摘要:Basically, they are just two different implementations of List interface.LinkedList is implemented with a double-linked list; ArrayList is implemented...
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/valid-anagram/ 题目: Given two strings s and t, write a function to determine if t is an anagram of s. For example
阅读全文
摘要:原题链接在这里:https://leetcode.com/problems/count-primes/ 题目: Given an integer n, return the number of prime numbers that are strictly less than n. Example
阅读全文