自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(673)
  • 收藏
  • 关注

原创 开源APP-LeeCo

开源APP-LeeCo近来找时间把自己去年构思的一个APP写了出来,并没有多少技术含量,主要运用到了Bmob后台、Picasso图片加载,还有一些自定义控件。这里图方便直接把中文README复制过来了,代码都已开源。 项目地址:LeeCoLeeCo LeeCo,超过300道面试算法题,29个分类,详尽的题解、讨论和评论英文文档README.md下载APK Github 二维码 Bugly:

2016-03-05 11:29:47 1643 1

原创 开源APP CoCoin

CoCoin CoCoin,一款多视图记账APP英文文档README.md 下载APK 二维码: 备注在GIF文件夹里有一些相关的gif。如果您之前安装了V1.1.0版本,建议先卸载V1.1.0版本再安装V1.2.0,因为V1.1.0并不是正式版。介绍概况 您可以使用CoCoin轻松记账,并使用密码来保护您的账本。账本密码会在您第一次使用CoCoin的时候被设置。在记账的时候,您可以通过左

2016-01-11 23:20:20 2609 25

原创 LeetCode H-Index

LeetCode H-Index题目 Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher’s h-index. According to the definition

2016-01-08 15:27:15 678 7

原创 LeetCode Add Digits

LeetCode 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

2016-01-07 00:27:08 499

原创 LeetCode Ugly Number

LeetCode Ugly Number题目 Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugl

2016-01-07 00:25:34 484

原创 LeetCode Missing Number

LeetCode 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.

2016-01-06 23:26:59 394

原创 LeetCode Search a 2D Matrix II

LeetCode Search a 2D Matrix II题目 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

2016-01-06 23:25:01 373

原创 LeetCode Binary Tree Paths

题目 Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are: [“1->2->5”, “1->3”]代码class Sol

2016-01-06 23:21:59 333

原创 LeetCode Different Ways to Add Parentheses

LeetCode Different Ways to Add Parentheses题目 Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators.

2016-01-05 18:43:08 383

原创 LeetCode Search a 2D Matrix II

LeetCode Search a 2D Matrix II题目 Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted in ascending

2016-01-05 16:51:09 335

原创 Android SharedPreferences安全存储/AutoCompleteTextView使用/文件读写

Android SharedPreferences安全存储/AutoCompleteTextView使用/文件读写计应一 13331091 黄伟平SharedPreferencesAndroid中最为简单的存储形式就是通过Sharedpreferences来存储数据,通过调用简单的接口(SharedPreferences的其实是个interface),可以将简单的键值对写在App对应的文件夹中的一个

2015-12-03 21:24:02 880

原创 LeetCode Shortest Word Distance III

LeetCode Shortest Word Distance III题目服务器抽风无法上传图片。 This is a follow up of Shortest Word Distance. The only difference is now word1 could be the same as word2. Given a list of words and two words

2015-11-26 15:13:03 455

原创 LeetCode Shortest Word Distance II

LeetCode Shortest Word Distance II题目思路跟上一题一样,但是在这题的背景下,求最短距离的函数将会被调用多次。因此我们可以先把字符串的每个位置都记录下来,这样找最短距离的时候就好很多。而且,记录位置的时候都是有序的,这样,在求最短距离的时候就类似于归并排序,只需要O(n+m)的时间复杂度即可,其中n为word1的位置数量,m为word2的位置数量。那为什么不直接用一个

2015-11-26 14:53:01 600

原创 LeetCode Shortest Word Distance

LeetCode Shortest Word Distance题目思路直接对两个目标字符串进行定位,然后更新最小距离即可。O(n),注意循环最好倒过来,这是因为这样的话words.size()方法只需要调用一次,如果写成i < words.size()的话会增加不必要的耗时。代码class Solution {public: int shortestDistance(vector<stri

2015-11-26 14:03:27 415

原创 LeetCode Valid Anagram

啊飒飒大

2015-11-24 09:00:44 448

原创 服务与多线程-简单音乐播放器

服务与多线程-简单音乐播放器要实现简单的音乐播放器,总是离不开服务和线程。因为服务可以让我们的程序在后台继续播放音乐, 而音乐播放器总是少不了进度条,进度条随着音乐播放进度的实时更新又需要用子线程更新UI以免主线程阻塞。服务关于服务的几点:创建服务要依次经过onCreate()方法和onStartCommand()方法,如果服务已经被创建,再次创建只会调用onStartCommand()方法服务

2015-11-21 21:51:41 3235

原创 从Fragment中传数据到Activity

从Fragment中传数据到Activity背景这是在项目中遇到的问题。在一个Activity中,有viewpager,viewpager里面放置的当然那是fragment了,然后fragment中有button什么的,在点击button的时候,希望能够改变Activity中的一些数据。 比如最常见的通过viewpager选择标签等。 之前想到的解决办法是直接将Activity中的控件等需要接受

2015-11-18 01:00:29 781

原创 静态广播和动态广播的区别

静态广播和动态广播的区别在Android中广播有两种实现方式:static broadcastdynamic broadcast两种广播有如下区别:生存期,静态广播的生存期可以比动态广播的长很多,因为静态广播很多都是用来对系统时间进行监听,比如我们可以监听手机开机。而动态广播会随着context的终止而终止优先级动态广播的优先级比静态广播高动态广播无需在AndroidManifest.x

2015-11-14 18:55:18 11643

原创 Sicily 1041. Pushing Boxes

Sicily 1041. Pushing Boxes嗯,好久没动过Sicily了。 Scrap cars in a junk yard are crushed in a device that pushes the car in from the sides, from the front and back, and from the top and bottom. The res

2015-11-07 11:08:24 738

原创 在Android studio中建立Java工程

在Android studio中建立Java工程Android studio是基于IntelliJ IDEA的,所以当然是可以建立Java工程的,步骤如下:新建Android工程 新建完成后: 切换到project视图 把settings.gradle中的语句都删掉 也就是删掉这一句: 同步Gradle 在进行了第3步之后,应该会有如下提示: 点击Sync Now,如果没有弹出提示

2015-11-07 01:24:07 5102

原创 LeetCode Summary Ranges

Summary Ranges题目思路直接做代码class Solution {public: vector<string> summaryRanges(vector<int>& nums) { vector<string> ans; if (nums.size() == 0) return ans; int startPosition = 0

2015-07-12 08:43:22 686

原创 LeetCode OJ Basic Calculator II

Basic Calculator II题目思路和这个一样:Basic Calculator I代码class ExpressionTransformation {public: string trans_to_postfix_expression_to_s(string); // 将得到的表达式转化为后缀表达式 long long int calculate_from_postf

2015-07-11 08:05:14 792

原创 Sicily 14173. Administrative Difficulties

Sicily 14173. Administrative Difficulties题目思路直接模拟代码#include <iostream>#include <string>#include <map>#include <vector>#include <cmath>using namespace std;class CAR {public: int catalogP, pick

2015-06-14 10:09:11 772

原创 LeetCode Basic Calculator

LeetCode Basic Calculator题目思路其实就是前中后缀表达式的转换和计算; 以前写过一个类:前中后缀表达式计算类 但是由于类有点大,只能拆开交(为了检测正确性);代码转为前缀计算class ExpressionTransformation {public: string trans_to_prefix_expression_to_s(string); // 将得到

2015-06-13 09:36:07 1568

原创 LeetCode Implement Stack using Queues

LeetCode Implement Stack using Queues题目思路就是个模拟; 如果把队头当做栈顶,只是push函数比较麻烦; 如果把队尾当做栈顶,pop和top函数都比较麻烦; 这里采用第一种方法;代码class Stack {public: void push(int x) { Q.push(x); int size = Q.siz

2015-06-13 09:35:40 885

原创 LeetCode Invert Binary Tree

LeetCode Invert Binary Tree题目思路没什么思路可言; 真不敢相信他写不出;代码struct TreeNode* invertTree(struct TreeNode* root) { if (root == NULL) return root; invertTree(root->left); invertTree(root->right);

2015-06-13 09:34:57 1995

原创 LeetCode Rectangle Area

LeetCode Rectangle Area题目思路刚开始自己写别提WA多少遍了; 后来看到标达真的被惊讶到了; 代码可以这么美;代码自己的#define min(A, B) (A > B ? B : A)bool pointInRectangle(int px, int py, int ax, int ay, int bx, int by) { return ax <= px &&

2015-06-13 09:34:33 999

原创 LeetCode Count Complete Tree Nodes

LeetCode Count Complete Tree Nodes题目思路这个树会灰常的大; 先沿着左右两遍计算深度,如果深度一样直接代公式算; 如果深度不一样,那就找最下面一层的断点;代码int maxD, num;int calDeepFromRight(struct TreeNode* root) { int ans = 0; while (root) {

2015-06-07 09:32:19 1187

原创 LeetCode Contains Duplicate III

LeetCode Contains Duplicate III题目思路我的方法是先用一个结构体,存下每个数字的值和其原坐标; 然后根据值大小排序; 接着遍历每一个数字num[i].val; 利用二分查找找到刚好比num[i].val - t - 1大的数字的坐标; 然后根据坐标判断是否存在值即可; 关于二分查找可见:Binary Search代码struct num { int p

2015-06-06 08:46:09 1417

原创 LeetCode Maximal Square

LeetCode Maximal Square题目思路思路还是很容易理解的,用DP; 令dp[i][j]表示以matrix[i][j]为正方形右下角的点时所能形成的最大面积; 公式显而易见,在代码中; 这题用宏定义定义MIN的时候犯了个错误耽误了很多时间; 那就是忘记加括号,要知道宏定义是直接替换;代码#define MIN(i, j) (i < j ? i : j)int maximalS

2015-06-06 08:40:42 1999

原创 二分查找 Binary Search

二分查找 Binary Search写在最前其实关于二分查找,网上已经有很多很多了; 这里仅仅是把一些有特殊要求的二分查找总结一下; 简单的测试好像并没有什么错; 如果有,希望能提出;代码#include <iostream>#include <vector>#include <iomanip>using namespace std;vector<int> test;int binary

2015-06-06 08:39:02 1265

原创 LeetCode Contains Duplicate II

LeetCode Contains Duplicate II题目思路跟Contains Duplicate一模一样,加个坐标判断即可。代码bool containsNearbyDuplicate(int* nums, int numsSize, int k) { if (numsSize <= 1) return false; int length = 100007; if

2015-06-02 08:08:36 1305 4

原创 Sicily 14551. Jury Jeopardy

Sicily 14551. Jury Jeopardy题目思路给定DFS路径,还原地图。代码#include <stdio.h>#include <string.h>const short DIR[4][2] = { 0, 1, 1, 0, 0, -1, -1, 0 };int main() { int caseNum; scanf("%d", &caseNum); pri

2015-06-02 07:06:54 939

原创 Sicily 14517. Eco-driving

Sicily 14517. Eco-driving题目思路直接看了题解- -; 在0到π之间二分,如果中间值可行,缩小右边界(让最大角尽可能小); 如果不可行,增大左边界(最大角已经不能再小); 重复40次的答案基本和标达无差了; 然而这并没有什么*用; 因为超时了,感觉是Sicily的时间限制不太合理; 你这可有多个cases啊; 直接用题解标达都没有办法过的; 于是; 我祭上了

2015-05-28 08:41:15 1071

原创 LeetCode Contains Duplicate

LeetCode Contains Duplicate题目思路刚开始还以为是什么异或判重; 后来发现是自己想错了- -; 还是哈希好点。代码bool containsDuplicate(int* nums, int numsSize) { if (numsSize <= 1) return false; int length = 100007; if (numsSize

2015-05-26 08:23:43 1189

原创 LeetCode Shortest Palindrome

LeetCode Shortest Palindrome题目思路其实原本想了一种算法,自己算了下大概复杂度为O(n^2); 想着定是不过了,于是看了Discuss里面的题解; 附上链接:KMP思路题解; 而后把原来的题解翻译了一下,改成了C语言的; 详见代码。代码//通过构造一个字符串S,再利用KMP算法可以解决这个问题//其中S=(输入的s)+(一个绝不会在s中出现的符号,比如#)+(s

2015-05-26 08:22:42 1265

原创 Sicily 14515. Cookie Selection

Sicily 14515. Cookie Selection题目思路用两个堆来放全部数就好了; 每个堆放一半; 题目说得这么长几个意思- -。代码#include <queue>#include <vector>#include <functional>#include <stdio.h>using namespace std;int main() { priority_queue

2015-05-26 08:21:43 879

原创 LeetCode Kth Largest Element in an Array

LeetCode Kth Largest Element in an Array题目思路利用快排的思想,每次都能得到一个位置mid; 并且我们知道在mid之前的数都是大于nums[mid]; 并且我们知道在mid之后的数都是小于nums[mid]; 根据K和mid的大小即可继续划分下去; 直到找到目标。代码int Adjust(int * nums, int l, int r) {

2015-05-25 09:00:06 2075

原创 LeetCode Combination Sum III

LeetCode Combination Sum III题目思路DFS代码class Solution {public: vector<vector<int>> Ans; vector<int> AnAns; int K; int N; vector<vector<int> > combinationSum3(int k, int n) {

2015-05-25 08:59:41 912

原创 LeetCode Word Search II

LeetCode Word Search II题目思路结合Trie和DFS即可。 用C写真是虐心。 也不知道有没有内存泄露。 如有,望指正。代码struct TrieNode { char c; // sons for "abcdefghijklmnopqrstuvwxyz\0" struct TrieNode * son[27]; };struct TrieNod

2015-05-21 08:13:25 1163

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除