- 博客(26)
- 收藏
- 关注
原创 LeetCode OJ 14 Longest Common Prefix
题目:Write a function to find the longest common prefix string amongst an array of strings.难度:Easy思路: 从头开始比较每个字符串,不等就停止循环即可代码如下class Solution {public: string longestCommonPrefix(vecto
2015-10-21 07:26:02 404
转载 LeetCode OJ 13 Roman To Integer
参考http://blog.csdn.net/jellyyin/article/details/13165731代码如下class Solution {public: int romanToInt(string s) { map mapValue; mapValue.insert(pair('I',1)); mapValue.inser
2015-10-21 07:13:10 403
原创 LeetCode OJ 12 Integer to Roman
题目:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.难度: medium思路:找到罗马数字对应阿拉伯数字的规律即可。将数字对应序列从大到小排列,每次减掉可以减掉的最大数,换成对应的罗马字母即可
2015-10-21 06:35:18 548
原创 LeetCode OJ 11 Container With Most Water
题目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i,
2015-10-21 06:16:45 439
原创 LeetCode OJ 9 Palindrome Number
题目:Determine whether an integer is a palindrome. Do this without extra space.难度easy思路:每一个提取最高位和最低位进行比较即可代码如下using namespace std;class Solution {public: bool isPalindrome(int x) {
2015-10-21 01:28:06 430
转载 LeetCode OJ 123 Best Time to Buy and Sell Stock III
题目: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. You may complete at most k transactions.Note:Y
2015-10-21 01:07:43 473
原创 LeetCode OJ 123 Best Time to Buy and Sell Stock III
题目: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. You may complete at most two transactions.Note:
2015-10-20 01:13:02 490
原创 LeetCode OJ 121 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.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of th
2015-10-19 12:33:20 423
原创 LeetCode OJ 198 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 adjac
2015-10-18 00:32:35 483
原创 LeetCode OJ 05 Longest Palindromic Substring
题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.难度:medium
2015-10-13 23:42:17 419
转载 LeetCode OJ 03 Longest Substring Without Repeating Characters
题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3.
2015-09-24 03:45:28 355
转载 LeetCode OJ 02 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
2015-09-24 00:54:08 401
转载 LeetCode OJ 01 Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe
2015-09-24 00:26:26 350
原创 LeetCode OJ 0 Reverse Integer
题目难度:easyReverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321思路:题目本身很简单,但是需要考虑到超出int类型的情况,网上有一些accept的code在本机测试的时候其实是错的,也不知道为什么online judge就过了。
2015-08-27 12:33:28 422
原创 LeetCode OJ 06 ZigZag Conversions
题目难度:easyThe string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H
2015-08-27 08:13:42 515
转载 LeetCode OJ 4 Median of Two Sorted Arrays
难度:hardThere are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).思路参考:http:
2015-07-12 19:42:06 470
原创 LeetCode OJ 81 Search in Rotated Sorted Array II
Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the
2015-07-11 11:24:48 483
原创 LeetCode OJ 33 Search in Rotated Sorted Array
难度:hard由此可见leetcode的hard难度比较于acm是偏简单一些的。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).You are given a tar
2015-07-06 18:21:08 571
原创 LeetCode OJ 80 Remove Duplicates from Sorted ArrayII
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first fi
2015-07-05 17:55:53 576
原创 Android 百度地图使用时出现inflating class com.baidu.mapapi.map.MapView错误的解决方案
在使用百度地图的activity的oncreate()方法第一行加上一句inflating class com.baidu.mapapi.map.MapView即可正常使用
2015-05-25 15:11:45 3015 1
原创 LeetCode OJ 26 Remove Duplicates from Sorted Array
毕设做累了,无聊刷个题压压惊。今天是第一次做leetcode的题目,做题顺序按照分类来做。该题分类为线性表,题目难度为简单。Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not
2015-05-25 14:30:42 621
原创 Android向PHP后台服务器传中文出现乱码的解决办法
之前做项目的时候一直是Android向PHP后台传英文或者数字,今天第一次传了一个中文参数过去,结果出现了乱码。在一段时间的分析之后,问题出在PHP后台页面的编码问题。我Android的发送数据的时候采用了UTF-8的编码格式,而PHP页面默认的编码格式并非UTF-8,修改之后即可正常运行。Android端的代码如下public static String busInfoQuery(Strin
2015-05-19 16:24:48 1100
原创 搜索框输入文字显示搜索结果的效果
有的时候我们在使用app的时候,在搜索框上输入开头几个字符就会弹出一个下拉框匹配出开头字符相符的搜索结果,这个效果是怎么做出来的呢。有的人用contentProvider做,而我采用的是一个比较偷懒的方法,用autoCompleteTextView做的。布局文件中需要有这样一个控件<AutoCompleteTextView android:id="@+id/autoComple
2015-05-16 20:01:25 1641
原创 ListView与适配器的使用
今天打算修改一个drawerLayout的源码时准备修改一个ListView,原版的ListView中的Item均为TextView,然而我想做成ImageView+TextView的。而之前由于突击学习对ListView不甚了解,在修改Item的xml文件后报错。之后查阅了一下资料,有关ListView和Adapter的使用可以参考此文http://l62s.iteye.com/blog
2015-05-13 15:39:36 475
原创 getActionBar().setDisplayHomeAsUpEnabled(true)这句报空指针异常的解释
毕业设计做Android开发已经一段时间了,早期遇到了很多错误都没有记录解决方案,最近顿感记忆力衰退,赶快随时记录一下一天中遇到的错误。今天晚上在运行代码时 getActionBar().setDisplayHomeAsUpEnabled(true)报错空指针异常,查了一下资料,最后得意解决。http://stackoverflow.com/questions/18602953/getac
2015-05-11 21:25:58 4028
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人