- 博客(23)
- 资源 (4)
- 收藏
- 关注
原创 Leetcode 230. Kth Smallest Element in a BST
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.Follow up: What if the BST is mod
2016-06-29 22:05:42 248
原创 Leetcode 365. Water and Jug Problem
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres using these two ju
2016-06-27 16:27:53 595
原创 Leetcode 328. Odd Even Linked List
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in plac
2016-06-17 22:15:30 219
原创 Leetcode 62. 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 is trying to reach the botto
2016-06-17 21:11:38 203
原创 Leetcode 67. Add Binary
Given two binary strings, return their sum (also a binary string).For example, a = “11” b = “1” Return “100”.按照二进制的加法规则进行编程就行了class Solution {public: string addBinary(string a, string b) {
2016-06-17 15:04:39 258
原创 Leetcode 213. House Robber II
Note: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all
2016-06-17 11:23:18 184
原创 Leetcode 337. House Robber III
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. After a tour,
2016-06-17 10:28:59 223
原创 Leetcode 319. Bulb Switcher
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or turning off i
2016-06-16 22:41:06 195
原创 Leetcode 219. Contains Duplicate II
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.最开始写了下面这个错误
2016-06-16 21:59:18 297
原创 Leetcode 347. Top K Frequent Elements
Given a non-empty array of integers, return the k most frequent elements.For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number of unique ele
2016-06-15 20:51:40 321
原创 Leetcode 268. Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example, Given nums = [0, 1, 3] return 2.Note: Your algorithm should run in line
2016-06-15 17:02:12 185
原创 Leetcode 318. Maximum Product of Word Length
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case lette
2016-06-15 16:51:44 212
原创 Leetcode 343. Integer Break
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2, return 1
2016-06-15 16:07:06 181
原创 Leetcode 260. Single Number III
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given nums = [1,
2016-06-14 11:36:55 241
原创 Leetcode 28. Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.这道题目主要有这三种方法。在Leetcode上并没有展现KMP和BM算法的优势,应该与OJ的测试样例有关; 暴力解法时间复杂度 O(MN), KMP 为
2016-06-13 18:13:39 270
转载 字符串匹配的Boyer-Moore算法
转载自:http://www.ruanyifeng.com/blog/2013/05/boyer-moore_string_search_algorithm.html上一篇文章,我介绍了KMP算法。 但是,它并不是效率最高的算法,实际采用并不多。各种文本编辑器的”查找”功能(Ctrl+F),大多采用Boyer-Moore算法。Boyer-Moore算法不仅效率高,而且构思巧妙,容易理解。1977年
2016-06-12 23:54:52 274
转载 字符串匹配的KMP算法
本篇关于KMP算法的讲解是我搜集到的认为讲的最简单易懂的一篇,分享给大家一起学习。转载自:http://www.ruanyifeng.com/blog/2013/05/boyer-moore_string_search_algorithm.html 字符串匹配是计算机的基本任务之一。 举例来说,有一个字符串”BBC ABCDAB ABCDABCDABDE”,我想知道,里面是否包含另一个字符串”ABC
2016-06-12 23:36:50 225
原创 Leetcode 165. 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 version strings are non-empty and conta
2016-06-11 17:07:14 173
原创 Leetcode 303. Range Sum Query - Immutable
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example: Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1 sumRange(2, 5) -> -1 sumRange(0, 5
2016-06-07 17:04:26 180
原创 Leetcode 190. Reverse Bits
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110
2016-06-07 15:55:19 161
原创 Leetcode 125. Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, “A man, a plan, a canal: Panama” is a palindrome. “race a car” is not a palin
2016-06-07 15:33:57 246
原创 Leetcode 278. First Bad Version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the
2016-06-07 11:10:00 156
原创 Leetcode 189. 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].题目要求讲一个数组循环右移k位。方法一:严格按照右移定义。可按k和(1/2)n的相对大小设计左移和右移,但是时间
2016-06-06 22:40:23 237
CNN模型简单介绍(LeNet,AlexNet,VGG,GoogLeNet,ResNet,GAN,R-CNN)
2017-01-16
CNN模型简单介绍(LeNet,AlexNet,VGG,GoogLeNet,ResNet,GAN,R-CNN)
2017-01-16
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人