• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
xiaoba1203
记录leetcode之路
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

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. 主要是思考清楚计算过程: 将一个数进行因式分解, 阅读全文
posted @ 2016-11-30 21:52 xiaoba1203 阅读(130) 评论(0) 推荐(0)
✡ 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: 很简 阅读全文
posted @ 2016-11-30 17:28 xiaoba1203 阅读(215) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-30 17:15 xiaoba1203 阅读(185) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-30 15:53 xiaoba1203 阅读(491) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-30 15:12 xiaoba1203 阅读(293) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-30 14:48 xiaoba1203 阅读(149) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-30 14:35 xiaoba1203 阅读(173) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-29 16:58 xiaoba1203 阅读(10063) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-29 16:11 xiaoba1203 阅读(320) 评论(0) 推荐(0)
✡ 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, 阅读全文
posted @ 2016-11-29 14:30 xiaoba1203 阅读(268) 评论(0) 推荐(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、还有很 阅读全文
posted @ 2016-11-28 23:06 xiaoba1203 阅读(639) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-28 17:14 xiaoba1203 阅读(386) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-28 15:11 xiaoba1203 阅读(347) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-28 14:20 xiaoba1203 阅读(516) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-28 12:56 xiaoba1203 阅读(285) 评论(0) 推荐(0)
最小二乘法 java
摘要:java中调用commons.math3使用最小二乘法。 在这里记录一下使用方法。 阅读全文
posted @ 2016-11-27 17:50 xiaoba1203 阅读(1871) 评论(0) 推荐(0)
Tips
摘要:1.StringBuffer 与 StringBuilder a.执行速度:StringBuilder > StringBuffer => 单线程操作大量数据 : StringBuilder b.StringBuilder:线程非安全的 StringBuffer :线程安全 => 多线程操作大量数据 阅读全文
posted @ 2016-11-23 15:23 xiaoba1203 阅读(158) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-19 23:38 xiaoba1203 阅读(226) 评论(0) 推荐(0)
✡ 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 阅读全文
posted @ 2016-11-19 23:20 xiaoba1203 阅读(228) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-19 15:45 xiaoba1203 阅读(326) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-19 14:55 xiaoba1203 阅读(136) 评论(0) 推荐(0)
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. 阅读全文
posted @ 2016-11-18 23:25 xiaoba1203 阅读(299) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-18 22:42 xiaoba1203 阅读(179) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-18 21:49 xiaoba1203 阅读(271) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-18 18:12 xiaoba1203 阅读(537) 评论(0) 推荐(0)
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、比较直观的方法是,三层循环,以任意两点划线,判断第三个点 阅读全文
posted @ 2016-11-18 16:55 xiaoba1203 阅读(352) 评论(0) 推荐(0)
leetcode 148. Sort List ----- java
摘要:Sort a linked list in O(n log n) time using constant space complexity. 排序,要求是O(nlog(n))的时间复杂度和常数的空间复杂度,那么就使用归并就可以了。 阅读全文
posted @ 2016-11-18 11:19 xiaoba1203 阅读(369) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-16 16:43 xiaoba1203 阅读(147) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-16 16:05 xiaoba1203 阅读(526) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-16 11:29 xiaoba1203 阅读(206) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-16 11:02 xiaoba1203 阅读(278) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-16 10:35 xiaoba1203 阅读(293) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-15 17:55 xiaoba1203 阅读(251) 评论(0) 推荐(0)
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、设置两 阅读全文
posted @ 2016-11-15 16:32 xiaoba1203 阅读(157) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-15 16:06 xiaoba1203 阅读(331) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-15 14:59 xiaoba1203 阅读(214) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-15 12:00 xiaoba1203 阅读(195) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-15 10:11 xiaoba1203 阅读(144) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-14 16:40 xiaoba1203 阅读(111) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-14 16:33 xiaoba1203 阅读(363) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-14 14:30 xiaoba1203 阅读(241) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-14 10:54 xiaoba1203 阅读(201) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-11 16:31 xiaoba1203 阅读(182) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-10 18:04 xiaoba1203 阅读(298) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-10 17:29 xiaoba1203 阅读(663) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-06 20:11 xiaoba1203 阅读(119) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-06 19:58 xiaoba1203 阅读(238) 评论(0) 推荐(0)
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, 阅读全文
posted @ 2016-11-06 18:35 xiaoba1203 阅读(263) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-06 17:53 xiaoba1203 阅读(351) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-05 15:25 xiaoba1203 阅读(488) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-05 14:33 xiaoba1203 阅读(153) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-05 12:29 xiaoba1203 阅读(165) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-02 17:37 xiaoba1203 阅读(210) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-02 17:11 xiaoba1203 阅读(145) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-02 16:37 xiaoba1203 阅读(369) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-01 23:58 xiaoba1203 阅读(238) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-01 22:15 xiaoba1203 阅读(193) 评论(0) 推荐(0)
leetcode 118 Pascal's Triangle ----- java
摘要:Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return 用的比价暴力的方法, 也是最快的。 阅读全文
posted @ 2016-11-01 21:52 xiaoba1203 阅读(167) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-01 21:38 xiaoba1203 阅读(276) 评论(0) 推荐(0)
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 阅读全文
posted @ 2016-11-01 18:11 xiaoba1203 阅读(133) 评论(0) 推荐(0)
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: 这道题就是将数变为只有右节点的树。 递归,不是很难。 递归的时候求出左节 阅读全文
posted @ 2016-11-01 15:16 xiaoba1203 阅读(227) 评论(0) 推荐(0)
 

公告


博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3