- 博客(17)
- 资源 (17)
- 问答 (3)
- 收藏
- 关注
原创 16. 3Sum Closest(47.2%)
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly
2016-01-27 19:58:30 431
原创 主元素问题
前提是主元素一定存在/** * 核心思想:在元素数组中,删去不同的两个元素,数组的主元素保持不变。 * */ public class MainE
2016-01-25 16:08:19 561
转载 15. 3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: Elements in a triplet (a,b,c) must be i
2016-01-22 20:18:18 423
原创 14. Longest Common Prefix(28.4%)
题目:Write a function to find the longest common prefix string amongst an array of strings. 解释:求输入字符串数组中最长的相同前缀public class Solution { public String longestCommonPrefix(String[] strs) { int
2016-01-21 11:22:30 374
转载 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, 0). Find two lin
2016-01-21 10:36:23 366
转载 10. Regular Expression Matching
Implement regular expression matching with support for ‘.’ and ‘*’.‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element.The matching should cover the entire input string
2016-01-20 09:51:36 530
转载 安卓中根据图片文件名获取图片资源ID
方法一: /** * 获取图片名称获取图片的资源id的方法 * @param imageName * @return */ public int getResource(String imageName) { Context ctx = getBaseContext(); int resId = getResources().getIdentif
2016-01-14 19:56:59 2902
原创 9. Palindrome Number(21.01%)
题目:Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string, note
2016-01-14 10:14:08 345
原创 8. String to Integer (atoi)(8.46%)
题目:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input case
2016-01-13 18:05:46 376
原创 7.Reverse Integer(16.45%)
题目:Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321理解:将输入的整数反向值输出,需要注意一点就是负号和反向之后值可能会超过int最大值的情况。public class Solution { public int reverse(int x) {
2016-01-13 15:41:12 423
原创 6.ZigZag Conversion(93.10%)
题目:The 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 N A P L S I I
2016-01-12 11:28:40 443
原创 5.Longest Palindromic Substring(59.30%)
题目: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.个人理解:求给定字符串的最长回文。 我首先想到
2016-01-09 19:18:09 386
原创 4.Median of Two Sorted Arrays(13.12%)
题目:There 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)).个人理解:给你两个已经排列好顺序的数组,求这两个数组的
2016-01-08 00:54:06 449
原创 3.Longest Substring Without Repeating Characters(7.66%)
刚开始的时候贪图便利,用Java自带的字符串方法进行操作,结果超时了:public class Solution { public int lengthOfLongestSubstring(String s) { int inputLength = s.length(); int longestLength = 0; for (int i = 0
2016-01-06 20:10:35 419
转载 1.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
2016-01-05 16:40:17 410
原创 2. Add Two Numbers官方通过版本(8.46%)
public class AddTwoNumbers { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { ListNode sumNumbers = new ListNode(0); // 进位 int forward = 0; // 遍历过程进行节点添加,开始的时候
2016-01-05 15:58:51 375
原创 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
2016-01-03 14:39:22 382
TA创建的收藏夹 TA关注的收藏夹
TA关注的人