- 博客(100)
- 资源 (22)
- 收藏
- 关注
原创 [leetcode]Summary Ranges
Summary Ranges Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].public class Solution {
2015-07-04 09:00:21
480
原创 [leetcode]Contains Duplicate II
Contains Duplicate II Given an array of integers and an integer k, find out whether there there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference
2015-06-12 16:03:13
393
原创 [leetcode]Contains Duplicate
Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should ret
2015-06-12 16:00:33
517
原创 [leetcode]Rectangle Area
Rectangle Area Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.
2015-06-12 10:32:54
413
原创 [leetcode]Add and Search Word - Data structure design
Add and Search Word - Data structure design Design a data structure that supports the following two operations:void addWord(word)bool search(word)search(word) can search a literal word
2015-05-16 16:23:54
528
原创 [leetcode]Subsets II
Subsets II Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set
2015-05-14 21:41:25
326
原创 [leetcode]Subsets
Subsets Given a set of distinct integers, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subs
2015-05-14 20:04:35
357
原创 [leetcode]Course Schedule II
Course Schedule II There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take cours
2015-05-14 09:53:51
872
原创 [leetcode]Clone Graph
Clone Graph 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 uniquely.We use # a
2015-05-13 10:18:22
398
原创 [leetcode]Minimum Size Subarray Sum
Minimum Size Subarray Sum Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead.
2015-05-13 09:34:09
467
原创 [leetcode]Unique Paths
Unique Paths A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time.The robot
2015-05-10 19:21:59
352
原创 [leetcode]Course Schedule
Course Schedule There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1
2015-05-10 19:11:50
791
原创 [leetcode]Implement Trie (Prefix Tree)
Implement Trie (Prefix Tree) Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase letters a-z.题意:实现字典树的插入,查找,前缀方法
2015-05-10 16:53:10
992
原创 [leetcode]Reverse Linked List
Reverse Linked List Reverse a singly linked list.click to show more hints.Hint:A linked list can be reversed either iteratively or recursively. Could you implement both?题目描述:反转链表解法
2015-05-10 15:28:44
386
原创 [leetcode]Implement strStr()
Implement strStr() Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The signature of the
2015-05-01 22:28:39
569
原创 [leetcode]Count Primes
Count Primes Description:Count the number of prime numbers less than a non-negative number, nCredits:Special thanks to @mithmatt for adding this problem and creating all test cases.
2015-05-01 11:19:33
494
原创 [leetcode]Maximum Product Subarray
Maximum Product Subarray 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],the contiguou
2015-04-30 21:55:56
348
原创 [leetcode]Isomorphic Strings
Isomorphic Strings Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character m
2015-04-30 21:39:50
469
原创 [leetcode]Binary Tree Right Side View
Binary Tree Right Side View Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Give
2015-04-20 14:21:05
421
原创 [leetcode]Compare Version Numbers
Compare Version Numbers Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the vers
2015-04-19 13:32:28
450
原创 [leetcode]Intersection of Two Linked Lists
Intersection of Two Linked Lists Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1
2015-04-17 21:05:57
318
原创 [leetcode]Binary Search Tree Iterator
Binary Search Tree Iterator Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smalles
2015-04-17 20:42:46
406
原创 [leetcode]Excel Sheet Column Title
Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z
2015-04-17 19:41:00
449
原创 [leetcode]Find Minimum in Rotated Sorted Array II
Find Minimum in Rotated Sorted Array II Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?S
2015-04-17 19:28:30
319
原创 [leetcode]Find Minimum in Rotated Sorted Array
Find Minimum in Rotated Sorted Array 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
2015-04-17 18:53:43
421
原创 [leetcode]House Robber
House Robber You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them
2015-04-17 15:57:16
323
原创 [leetcode]Number of Islands
Number of Islands Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally
2015-04-14 14:53:32
329
原创 [leetcode]Largest Number
Largest NumberGiven a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.No
2015-04-12 22:22:19
398
原创 [leetcode]Rotate Array
Rotate Array Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as m
2015-04-12 22:16:26
351
原创 连连看的实现
连连看的实现 一种蛮力方法0折一条直线可以消除的1折两条直线可以消除的2折三条直线可以消除的如下图public class LianLianKan { public static void main(String[] args) { // TODO Auto-generated method stub int[][] a = /*{ {1
2015-04-12 22:07:54
621
转载 Java中间变量缓存机制
转自 http://blog.youkuaiyun.com/yangysng07/article/details/37911363Java中间变量缓存机制在java中,执行自增运算时,会为每一个自增操作分配一个临时变量,如果是前缀加(++i),就会“先自加1后赋值(给临时变量)”;如果是后缀加(i++),就会“先赋值(给临时变量)后自加1”。运算最终使用的,并不是变量本身,而是被赋了值的临时变
2015-02-13 20:51:41
503
原创 [leetcode]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 and it costs cost[i] of gas to trave
2014-07-23 21:00:59
516
原创 求两个数的最小公倍数
#include #include using namespace std; int pow(int a, int b){ int sum = 1; for(int i = 0; i < b; i++){ sum *= a; } return sum; }
2014-07-21 15:45:33
974
原创 [leetcode]Anagrams
Anagrams Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.题目意思
2014-07-17 15:44:39
553
原创 编译c文件出现的小bug--错误:程序中有游离的'\302'
0002200 302 240 302 240 \n 302 240 302 240 g _ p r i n t0002220 ( " P a d T e m p l a t e s0002240 f o r % s : \ n "
2014-07-15 17:44:42
2755
原创 [leetcode]Combination Sum II
Combination Sum II Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only
2014-06-18 08:51:54
607
原创 [leetcode]Reverse Nodes in k-Group
Reverse Nodes in k-Group Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out no
2014-06-17 22:01:14
401
原创 [leetcode]N-Queens II
N-Queens II Total Accepted: 8297 Total Submissions: 25938My SubmissionsFollow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct
2014-06-17 20:36:01
649
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人