11 2016 档案
✡ leetcode 172. Factorial Trailing Zeroes 阶乘中的结尾0个数--------- java
摘要:Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 主要是思考清楚计算过程: 将一个数进行因式分解,
阅读全文
✡ leetcode 171. Excel Sheet Column Number 字母转换为数字 --------- java
摘要:Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: 很简
阅读全文
✡ leetcode 170. Two Sum III - Data structure design 设计two sum模式 --------- java
摘要:Design and implement a TwoSum class. It should support the following operations: add and find. Design and implement a TwoSum class. It should support
阅读全文
✡ leetcode 169. Majority Element 求出现次数最多的数 --------- java
摘要: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
阅读全文
✡ leetcode 168. Excel Sheet Column Title 26进制数字 --------- java
摘要:Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 26进制的实现。 没什么难点。就是需要需要注意是 n = (n-1)/26
阅读全文
✡ leetcode 167. Two Sum II - Input array is sorted 求两数相加等于一个数的位置 --------- java
摘要:Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function
阅读全文
✡ leetcode 166. Fraction to Recurring Decimal 分数转换 --------- java
摘要:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating
阅读全文
✡ leetcode 165. Compare Version Numbers 比较两个字符串数字的大小 --------- java
摘要:Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assum
阅读全文
✡ leetcode 164. Maximum Gap 寻找最大相邻数字差 --------- java
摘要:Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solve it in linear time/space. Return
阅读全文
✡ leetcode 163. Missing Ranges 找出缺失范围 --------- java
摘要:Given a sorted integer array where the range of elements are in the inclusive range [lower, upper], return its missing ranges. For example, given [0,
阅读全文
✡ leetcode 161. One Edit Distance 判断两个字符串是否是一步变换 --------- java
摘要:Given two strings S and T, determine if they are both one edit distance apart. 给定两个字符串,判断他们是否是一步变换得到的。 在这里需要注意几点: 1、不等于1的变换都要返回false(包括变换次数等于0)。 2、还有很
阅读全文
✡ leetcode 159. Longest Substring with At Most Two Distinct Characters 求两个字母组成的最大子串长度 --------- java
摘要:Given a string, find the length of the longest substring T that contains at most 2 distinct characters. For example, Given s = “eceba”, T is "ece" whi
阅读全文
✡ leetcode 158. Read N Characters Given Read4 II - Call multiple times 对一个文件多次调用read(157题的延伸题) --------- java
摘要:The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number of characters read. For example, it retu
阅读全文
✡ leetcode 157. Read N Characters Given Read4 利用read4实现read --------- java
摘要:The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number of characters read. For example, it retu
阅读全文
✡ leetcode 156. Binary Tree Upside Down 旋转树 --------- java
摘要:156. Binary Tree Upside Down Add to List QuestionEditorial Solution My Submissions 156. Binary Tree Upside Down Add to List QuestionEditorial Solution
阅读全文
最小二乘法 java
摘要:java中调用commons.math3使用最小二乘法。 在这里记录一下使用方法。
阅读全文
Tips
摘要:1.StringBuffer 与 StringBuilder a.执行速度:StringBuilder > StringBuffer => 单线程操作大量数据 : StringBuilder b.StringBuilder:线程非安全的 StringBuffer :线程安全 => 多线程操作大量数据
阅读全文
✡ leetcode 162. Find Peak Element --------- java
摘要:A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its inde
阅读全文
✡ leetcode 160. Intersection of Two Linked Lists 求两个链表的起始重复位置 --------- java
摘要:Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to in
阅读全文
leetcode 155. Min Stack --------- java
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov
阅读全文
leetcode 154. Find Minimum in Rotated Sorted Array II --------- java
摘要:Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose a
阅读全文
leetcode 153. Find Minimum in Rotated Sorted Array --------- java
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element.
阅读全文
leetcode 152. Maximum Product Subarray --------- java
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4],t
阅读全文
leetcode 151. Reverse Words in a String --------- java
摘要:Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". Update (2015-02-12):For C pr
阅读全文
leetcode 150. Evaluate Reverse Polish Notation ------ java
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e
阅读全文
leetcode 149. Max Points on a Line --------- java
摘要:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 求二维平面上n个点中,最多共线的点数。 1、比较直观的方法是,三层循环,以任意两点划线,判断第三个点
阅读全文
leetcode 148. Sort List ----- java
摘要:Sort a linked list in O(n log n) time using constant space complexity. 排序,要求是O(nlog(n))的时间复杂度和常数的空间复杂度,那么就使用归并就可以了。
阅读全文
leetcode 147. Insertion Sort List ----- java
摘要:Sort a linked list using insertion sort. 插入排序。 /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNo
阅读全文
leetcode 146. LRU Cache ----- java
摘要:esign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the
阅读全文
leetcode 145. Binary Tree Postorder Traversal ----- java
摘要:Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [3,2,1]. Note: Recursive sol
阅读全文
leetcode 144. Binary Tree Preorder Traversal ----- java
摘要:Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [1,2,3]. Note: Recursive solu
阅读全文
leetcode 143. Reorder List ----- java
摘要: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
阅读全文
leetcode 142. Linked List Cycle II ----- java
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up:Can you
阅读全文
leetcode 141. Linked List Cycle ----- java
摘要:Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 判断是否成环 1、利用set,很简单,但是题目中说不要用额外的空间。 2、设置两
阅读全文
leetcode 140. Word Break II ----- java
摘要:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such p
阅读全文
leetcode 139. Word Break ----- java
摘要: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
阅读全文
leetcode 138. Copy List with Random Pointer ----- java
摘要:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy
阅读全文
leetcode 137. Single Number II ----- java
摘要: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 c
阅读全文
leetcode 136. Single Number ----- java
摘要:Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime complex
阅读全文
leetcode 135. Candy ----- java
摘要: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
阅读全文
leetcode 134. Gas Station ----- java
摘要: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
阅读全文
leetcode 133. Clone Graph ----- java
摘要: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
阅读全文
leetcode 132. Palindrome Partitioning II ----- java
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning
阅读全文
leetcode 131. Palindrome Partitioning----- java
摘要: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
阅读全文
leetcode 130. Surrounded Regions----- java
摘要: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
阅读全文
leetcode 129. Sum Root to Leaf Numbers ----- java
摘要: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
阅读全文
leetcode 128. Longest Consecutive Sequence ----- java
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given [100, 4, 200, 1, 3, 2],The longes
阅读全文
leetcode 127. Word Ladder ----- java
摘要:Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord,
阅读全文
leetcode 126. Word Ladder II ----- java
摘要:Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such th
阅读全文
leetcode 125. Valid Palindrome ----- java
摘要: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
阅读全文
leetcode 124. Binary Tree Maximum Path Sum ----- java
摘要:Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in th
阅读全文
leetcode 123. Best Time to Buy and Sell Stock III ----- java
摘要: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
阅读全文
leetcode 122. Best Time to Buy and Sell Stock II ----- java
摘要: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
阅读全文
leetcode 121. Best Time to Buy and Sell Stock ----- java
摘要: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
阅读全文
leetcode 120 Triangle ----- java
摘要: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
阅读全文
leetcode 115 Distinct Subsequences ----- java
摘要:Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from t
阅读全文
leetcode 119 Pascal's Triangle II ----- java
摘要:Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your algorithm to us
阅读全文
leetcode 118 Pascal's Triangle ----- java
摘要:Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return 用的比价暴力的方法, 也是最快的。
阅读全文
leetcode 117 Populating Next Right Pointers in Each Node II ----- java
摘要: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
阅读全文
leetcode 116 Populating Next Right Pointers in Each Node ----- java
摘要:Given a binary tree Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL
阅读全文
leetcode 114 Flatten Binary Tree to Linked List ----- java
摘要:Given a binary tree, flatten it to a linked list in-place. For example,Given The flattened tree should look like: 这道题就是将数变为只有右节点的树。 递归,不是很难。 递归的时候求出左节
阅读全文
|
|
|