- 博客(209)
- 资源 (1)
- 收藏
- 关注
原创 【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
2016-03-09 15:08:15 175
原创 【LeetCode】70. Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?【思路】斐波那契数列,第n阶是由第n-1阶和n-2阶的方
2016-03-09 14:53:39 172
原创 【LeetCode】83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3./** * Definition for s
2016-03-09 14:23:34 144
原创 【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
2016-03-09 13:59:58 188
原创 【LeetCode】9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.class Solution {public: bool isPalindrome(int x) { vector v; if(x==0) return true; if(x<0) ret
2016-03-09 12:57:28 140
原创 【LeetCode】234. Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?【思路一】将list反转到新list,后一一进行比较。/** * Definition for singly-linked list. *
2016-03-09 12:45:32 209
原创 【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
2016-03-09 11:25:18 207
原创 【LeetCode】235. Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betwee
2016-03-09 10:37:18 184
原创 【LeetCode】13. Roman to Integer && 12. Integer to Roman
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999./*1~9: {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};10~90: {"X", "XX",
2016-03-09 09:56:01 219
原创 【LeetCode】206. Reverse Linked List
Reverse a singly linked list.遍历该单链表,将节点一个一个摘下来,采用 头插法 插入另一条链表/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x)
2016-03-08 22:08:12 188
原创 【LeetCode】169. Majority Element
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 array is non-empty and the majority element
2016-03-08 21:01:26 182
原创 【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 jis at most k.【
2016-03-08 20:36:41 176
原创 【LeetCode】217. 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
2016-03-08 19:49:11 184
原创 【LeetCode】171. Excel Sheet Column Number && 168. Excel Sheet Column Title
171.Given a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 class So
2016-03-08 19:38:27 183
原创 【LeetCode】242. Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.[思路]用sorth函数将两字符串排
2016-03-08 19:05:00 227
原创 【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 addBin
2016-03-08 17:22:18 156
原创 【LeetCode】2. Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link
2016-03-08 15:13:12 189
原创 【LeetCode】111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.【思路】递归调用,注意判断树的深度应该到叶子节点,也就是左右
2016-03-08 12:37:32 192
原创 【LeetCode】100. 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.递归调用:/
2016-03-08 11:22:45 250
原创 【LeetCode】283. Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling you
2016-03-08 10:59:34 183
原创 【LeetCode】27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.c
2016-03-08 10:26:06 164
原创 【LeetCode】203. Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5在链表中移除目标值。 也是维护一个dummy n
2016-03-08 10:04:19 189
原创 【Android】android-ndk-r10环境搭建
今天尝试搭建android-ndk, 以前需要下载Cygwin再配置,过程复杂麻烦。ndk-r7版本以上就不需要了,可以直接下载配置。我下载的ndk-r10,参考了一些帖子,终于得到了sample的正确结果。我参考链接如下:http://blog.csdn.net/lovexieyuan520/article/details/43212333http://doc.okbase.ne
2016-03-02 16:17:50 1278
原创 【Android】使用VideoView播放视频
使用VideoView播放视频的步骤:1、界面布局文件定义VideoView组件,或在程序中创建。<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="m
2016-03-01 17:28:46 378
翻译 【Android】基于Service组件的简易音乐播放器
BroadcastReceiver是一种全局监听器,可以让不同组件之间进行通信。下面展示一个基于Service组件的音乐盒,音乐由后台运行的service组件播放,当后台播放状态改变时,通过发送广播通知前台Activity更新界面;当用户单击前台Activity界面按钮,发送广播通知后台Service改变播放状态。 MainActivity代码:public class MainAc
2016-02-26 16:46:23 684
原创 【Android】BroadcasetReceiver使用
BroadcasetReceiver本质是一种全局监听器,监听系统级的广播消息,拥有自己的进程;而各种OnXXXListenser是程序级的监听器,只运行在程序所在的进程中,当程序退出时,OnXXXListenser随之关闭。BroadcasetReceiver用于接收程序所发出的Broadca Intent,启动只需要要两步:1、创建需要启动BroadcasetReceiver的In
2016-02-26 10:22:46 1857
原创 【Android】SharedPreference使用
SharedPreference保存的数据主要是类似于配置信息格式的数据,是一个轻量级存储类。保存的数据主要是简单类型的key-value对。SharedPreference接口本身并没有写入数据的能力,而是通过SharedPreference的内部接口,调用edit()方法可获取它所对应的Editor对象。使用SharedPreferences保存数据,其背后是用xml文件存放数
2016-02-24 16:32:27 558
转载 【Android】Cannot reload AVD list问题
在Android studio中新建模拟器时出现cannot reload avd list问题错误: Cannot reload AVD list: cvc-enumeration-valid: Value ‘280dpi’ is not facet-valid with respect to enumeration ‘[ldpi, mdpi, tvdpi, hdpi, xhdpi,
2016-02-23 21:07:44 682
原创 【Android】Toast显示乱码解决办法
安卓程序运行时Toast中文显示乱码,解决方法是在Moudle:app中的bulid.gradle中增加android{compileOptions.encoding="GBK"}
2016-02-23 21:06:07 3443
原创 【Android】SQLite使用基础
package com.example.databasetest;import android.os.Bundle;import android.app.Activity;import android.content.ContentValues;import android.database.Cursor;import android.database.sqlite.SQLiteDat
2016-02-23 16:17:53 309
原创 【数据结构】二叉树
树的结构定义是一个递归的定义。1、二叉树的顺序存储结构:用一组地址连续的存储单元依次从上至下,从左至右,存储二叉树上的结点元素。即第i个结点元素存储在下标第i-1的位置上。#define MAX_SIZE 100typedef TElemType SqBiTree[MAX_SIZE] //0 号单元存储根节点2、二叉树的二叉链表存储表示typedef struct B
2016-01-21 16:37:19 252
原创 【C++】优先队列priority_queue
优先队列是队列的一种,允许用户对队列中存储的元素设置优先级。按照数据的优先级来对队列中的数据进行动态的排序。每次的push和pop操作,队列都会动态的调整。所以我们无论按照什么顺序push一堆数据,最终在队列里总是top出最大的元素。1、标准库默认使用元素类型的priority_queueint> pq;2、数据越小,优先级越高p
2016-01-21 15:11:16 4378 1
原创 【Android】ExpandableListView示例
ExpandableListView使用示例:首先是布局文件:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
2016-01-18 16:07:47 322
原创 【Java】IO流基础知识
一、Java的输入、输出流主要由InputStream/Reader、 OutputStream/Writer作为抽象基类,InputStream、OutputStream所操作的数据单元是8位的字节流,而Reader/Writer所操作的数据单元是16位的字符流。下面是使用示例://FileInputStreamTest>>>>>>>>>>>>>>>>>>>>>>>>>//和Input
2016-01-15 11:09:19 302
翻译 【Android】使用SeekBar调整图像的色度、饱和及度亮度
SeekBar通过滑块位置来标识数值,且允许用户拖动滑块来改变值。下面利用三条SeeKBar来调整图片的色度(Hue)、饱和度(Saturation)、亮度(Lum)。布局文件为一个ImageView,三条SeekBar,布局简单,在此省略。首先创建一个图像处理类ImageHelper:public class ImageHelper { public static Bitma
2016-01-10 21:25:59 1110
原创 【Android】Android 基础知识
DDMS调试环境,全称是Dalvik Debug Monitor Service.Android平台的内核是基于Linux的,所使用的虚拟机是Dalvik是虚拟机,Dalvik所执行的是*.dex文件。R.java文件是由aapt工具根据应用中的资源文件来自动生成的,可以理解为Android应用的资源字典。XML定义用户界面,Java负责业务实现。这样可以降低程序的耦合性。Serv
2016-01-10 20:23:38 296
原创 【Java】定时器Timer的使用
1、使用java.util.Timer工具类可以周期性执行任务,或从指定时间开始执行。示例1:Android开发中,3秒后跳转到新ActivityTimer timer = new Timer(); TimerTask task = new TimerTask() { @Override public void run() {
2016-01-10 15:36:30 654
原创 【Android】利用ArrayAdapter/SimpleAdapter创建ListView
创建SimpleAdapter对象时,需要5个参数SimpleAdapter mSimpleAdapter = new SimpleAdapter(context, data, resource, from ,to);其中:context 上下文,当前Activity,即this.data 为数据源,是List>类型的对象集合,每个Map对应一行列表项, 每个Map(键-值对)
2016-01-08 23:03:22 418
转载 【Android】ViewPager实现Tab布局
ViewPager是android扩展包v4包中的类,这个类可以让用户左右切换当前的view。从这个描述中我们知道几点: 1)ViewPager类直接继承了ViewGroup类,所有它是一个容器类,可以在其中添加其他的view类。 2)ViewPager类需要一个PagerAdapter适配器类给它提供数据。 3)ViewPager经常和Fragmen
2016-01-08 19:47:08 379
原创 【Android】利用Bundle在不同Activity之间传递数据
Activity启动其他Activity有两种方法:1) startActivity(Intent intent)2) startActivityForResult(Intent intent, int requestCode)方法2)用于启动指定Activity。并且期望获得指定Activity返回的结果。例如,第一个界面需要做一个选择,选择内容在第二个界面上,需要返回选择的结果。这
2016-01-07 21:14:37 529
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人