- 博客(83)
- 资源 (4)
- 收藏
- 关注
原创 编程珠玑位逻辑运算实现位向量
看编程珠玑时,看到位逻辑运算实现位向量,思考了一些时间,做一些注释。/*位图数据结构:该数据结构描述了一个有限定义域内的稠密集合,其中每个元素最多出现一次并且没有其他任何数据结构与该元素相关联*/#include<iostream>#define BITSPERWORD 32#define N 10000000#define SHIFT 5#define MASK 0x1Fusing n
2015-10-11 17:21:39 1153
转载 ubuntu 正确安装jdk后,eclipse从快捷方式打开找不到jvm
今天重装系统,碰到了个古怪的问题,在正确配置好jdk路径后,解压缩版的eclipse能从命令行正常启动,从快捷方式启动时却提示找不到java路径。经过一番苦找之后,从正确安装jdk后,eclipse找不到jdk路径找到答案,原来建立eclipse快捷方式以后,从快捷方式启动,出现找不到jvm的情况,是因为eclipse默认从系统原来的jdk去找jvm。执行一下操作即可。sudo update-alt
2015-08-12 17:10:06 3011
原创 leetcode之Ugly Number II
Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly
2015-12-11 16:56:18 374
原创 leetcode之Perfect Squares
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, return
2015-12-03 22:29:19 409
原创 leetcode之Burst Balloons
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get nums[lef
2015-12-03 21:12:47 1469
原创 leetcode之Range Sum Query 2D - Immutable
Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2). The above rectangle (with the red borde
2015-12-03 08:58:25 359
原创 leetcode之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
2015-12-02 08:31:58 331
原创 Unique Binary Search Trees
Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 unique BST’s.1 3 3 2 1 \ /
2015-12-01 21:36:11 312
原创 leetcode之Triangle
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 following triangle [ [2], [3,4], [6,5,
2015-11-09 13:21:43 352
原创 leetcode之Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at any
2015-11-06 20:17:29 290
原创 leetcode之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 bot
2015-11-06 20:04:32 323
原创 leetcode之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 is that adjacent houses
2015-11-05 20:24:01 1364
原创 leetcode之Best Time to Buy and Sell Stock
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. Note: You may not engage in multiple transactions at the same
2015-11-04 21:54:53 499
原创 caffe安装过程中碰到的一些问题以及解决方案
最近一直在使用caffe,把自己安装以及使用过程中碰到的问题做个记录:convert_imageset.cpp:(.text.startup+0x5e1):对‘caffe::db::GetDB(std::string const&)’未定义的引用 convert_imageset.cpp:(.text.startup+0x719):对‘caffe::ReadImageToDatum(std::s
2015-10-26 12:25:15 25504 5
原创 LeetCode之Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Here
2015-10-24 21:32:08 386
原创 LeetCode之Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x. 题目解析:求整数x的平方根 思路:因为题目只是要求求整数的平方根,且返回的结果也是整数,因此该问题可以看做是一个搜索问题,搜索的范围为[0,x/2+1](sqrt(x)<=x/2+1可推导出(x−1)2>=0sqrt(x)<=x/2+1可推导出(x-1)^2>=0
2015-10-24 21:23:26 428
原创 LeetCode之Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray [4,−1,2,1] has the
2015-10-23 17:11:55 532
原创 LeetCode之Rotate Image
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up: Could you do this in-place?思路:先对matrix进行转置,然后reverse每一行中的数据,举个例子 1 2 3……………. 7 4 1……………
2015-10-14 22:58:28 862
原创 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 many solutions as you can, ther
2015-10-13 19:38:58 924
原创 编程珠玑一维向量旋转
编程珠玑第二章问题B提到了n元一维向量的旋转问题,并且提出了5种思路/************************************************************************* > File Name: rotateString.cpp > Author: kechuan > Mail: kechuan14@mails.ucas.ac
2015-10-12 23:25:25 3081
原创 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
2015-10-11 22:10:24 952
原创 Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 思路:遍历看输出结果是否相同即可,
2015-10-09 23:45:19 909
原创 Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, r
2015-10-09 23:09:18 863
原创 Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2].Note: Recursive solution is trivial,
2015-10-09 16:29:49 858
原创 Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra me
2015-10-08 23:00:11 897
原创 Count Primes
Description:Count the number of prime numbers less than a non-negative number, n.Credits: Special thanks to @mithmatt for adding this problem and creating all test cases.思路:采用筛选法,先把N个自然数按次序排列起来。1不是质数,
2015-10-08 22:45:01 880
原创 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. 思路:哈希表问题,
2015-10-08 19:24:05 816
原创 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 must be replaced with another chara
2015-10-08 19:15:00 887
原创 Word Pattern
Given a pattern and a string str, find if str follows the same pattern.Examples: pattern = “abba”, str = “dog cat cat dog” should return true. pattern = “abba”, str = “dog cat cat fish” should return
2015-10-08 18:56:05 1128
原创 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 return false if every element is
2015-10-08 12:26:37 994
原创 Reverse Words in a String
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 programmers: Try to solve it in-place in O(1) spa
2015-09-30 16:41:50 612
原创 Substring with Concatenation of All Words
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and wit
2015-09-30 12:51:19 377
原创 Minimum Window Substring
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example, S = “ADOBECODEBANC” T = “ABC” Minimum window is “BANC”.Note:
2015-09-29 15:46:14 324
原创 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
2015-09-28 22:31:19 554
原创 Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative. 思路:利用传统的方法,将乘法分解为加法,代码如下:class Solution {pu
2015-09-28 22:04:18 803
原创 Longest Valid Parentheses
Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.For “(()”, the longest valid parentheses substring is “()”, which has
2015-09-28 19:17:04 827
原创 Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defined as
2015-09-25 16:53:41 879
原创 Integer to English Words
Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.For example, 123 -> “One Hundred Twenty Three” 12345 -> “Twelve Thousand Three Hu
2015-09-25 16:11:09 813
原创 Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:a) In
2015-09-25 15:08:34 930
原创 Count and Say
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, …1 is read off as “one 1” or 11. 11 is read off as “two 1s” or 21. 21 is read off as “one 2, the
2015-09-16 20:27:31 853
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人