自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

可怜虫

把编程这件事做到极致

  • 博客(61)
  • 资源 (1)
  • 收藏
  • 关注

原创 78. Subsets I & II

QUESTION Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example, If nums = [1,2,3], a solution is:

2016-11-20 14:35:35 437

原创 238. Product of Array Except Self

QUESTION Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without division

2016-11-20 14:35:23 272

原创 106. Construct Binary Tree from Inorder and Postorder Traversal

QUESTION Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.THINKING利用中序遍历和后序遍历建立一个二叉树,考察数据结构的知识,递归。首

2016-11-19 15:54:43 258

原创 105. Construct Binary Tree from Preorder and Inorder Traversal

QUESTION Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.THINKING考察数据结构的问题和#106类似,特别需要注意的是递归的时候传递参数

2016-11-19 15:54:08 261

原创 442. Find All Duplicates in an Array

QUESTIONGiven an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without ext

2016-11-19 15:53:58 212

原创 120. Triangle

QUESTION 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],

2016-11-19 09:35:52 211

原创 228. Summary Ranges

QUESTION Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return [“0->2”,”4->5”,”7”].THOUGHT这道题不难,但是需要考虑很多细节,数组长度为0,为1,为2.都要去

2016-11-19 09:35:40 188

原创 377. Combination Sum IV

QUESTION Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. Example: nums = [1, 2, 3]tar

2016-11-17 12:34:11 199

原创 216. Combination Sum III

Question Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers. Example 1:

2016-11-16 12:30:16 178

原创 39. Combination Sum

QUESTION Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C unli

2016-11-16 12:30:04 221

原创 64. Minimum Path Sum

QUESTION 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

2016-11-16 12:29:52 275

原创 152. Maximum Product Subarray

QUESTION Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4], the contiguous subarray [2,3]

2016-11-14 14:42:48 208

原创 209. Minimum Size Subarray Sum

Question Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn’t one, return 0 instead. For example, given the

2016-11-14 14:42:37 145

原创 162. Find Peak Element

Question A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multi

2016-11-14 14:42:25 193

原创 153. Find Minimum in Rotated Sorted Array

Question 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). Find the minimum element. You may assume no duplic

2016-11-14 14:42:13 152

原创 152. Maximum Product Subarray

QUESTION Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4], the contiguous subarray [2,3]

2016-11-12 16:29:03 246

原创 209. Minimum Size Subarray Sum

Question Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn’t one, return 0 instead. For example, given the

2016-11-12 16:28:51 177

原创 162. Find Peak Element

Question A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multi

2016-11-12 16:28:38 156

原创 153. Find Minimum in Rotated Sorted Array

Question 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). Find the minimum element. You may assume no duplic

2016-11-12 16:28:23 161

原创 448. Find All Numbers Disappeared in an Array

QUESTION Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in thi

2016-11-11 09:23:23 4187 1

原创 229. Majority Element II

Question Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space. hint How many majority elemen

2016-11-11 09:23:10 139

原创 169. Majority Element

Question 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 majorit

2016-11-07 19:56:58 166

原创 88. Merge Sorted Array

Question Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough space (size that is greater or equal to m +

2016-11-07 19:56:44 113

原创 53. Maximum Subarray

Quesition 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 subarra

2016-11-06 13:35:26 174

原创 123. Best Time to Buy and Sell Stock III

QUESTION 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. N

2016-11-06 13:35:03 262

原创 121&122. Best Time to Buy and Sell Stock I II

Question I 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

2016-11-06 13:34:21 248

原创 66. Plus One

Question Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list.思路实质是用数组实现了

2016-11-05 13:04:08 136

原创 26. Remove Duplicates from Sorted Array

Question Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this i

2016-11-05 13:03:57 158

原创 414. Third Maximum Number

QUESTION Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n). Example 1:

2016-11-05 13:03:36 339

原创 189. Rotate Array

QUESTION 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

2016-11-05 13:03:14 133

原创 219. Contains Duplicate II

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

2016-11-05 13:02:22 148

原创 27. Remove Element

QUESTION Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in place with constant

2016-11-05 13:02:03 126

原创 283. Move Zeroes

Question 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

2016-11-05 13:01:41 117

原创 118. Pascal's Triangle

Question Given numRows, generate the first numRows of Pascal’s triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]思路一就是一个一个

2016-11-05 13:01:16 288

原创 1. Two Sum&15. 3Sum

Question Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution. Example:

2016-11-05 13:00:16 164

转载 Java数组声明、创建、初始化

本文讲述了Java数组的几个相关的方面,讲述了对Java数组的声明、创建和初始化,并给出其对应的代码。一维数组的声明方式:type var[]; 或type[] var;注:声明数组时不能指定其长度(数组中元素的个数),Java中使用关键字new创建数组对象,格式为:数组名 = new 数组元素的类型 [数组元素的个数]实例:TestNew.java:程序代码:

2016-05-26 10:25:38 750

原创 StringBuilder的用法

说明:1.JDK1.5之后出现了StringBuilder,一个可变的字符串序列2.他的用法基本StringBuffer相同3.StringBuilder和StringBuffer不同的地方在于 StringBuffer是线程安全的4.单线程、不需要线程安全的情况下,处于性能的考虑,优先选择StringBuilder5.更详细的API请参见 http://d

2016-05-23 22:03:23 566

转载 java字符串的操作

字符串遍历String str = "asdfghjkl";1.for(int i=0;i<str.length();i++){ char ch = str.charAt(i); }2.char[] c=str.toCharArray(); for(char cc:c){ ...//cc 直接用了} 3.for(int i=0;i

2016-05-12 09:00:51 292

原创 c语言怎么获取数组的长度

c语言中,定义数组后可以用sizeof命令获得数组的长度(可容纳元素个数)如:{int data[4];int length;length=sizeof(data)/sizeof(data[0]); //数组占内存总空间,除以单个元素占内存空间大小printf("length of data[4]=%d", length ); //输出length of data[4]=4

2016-05-09 08:06:47 2412

原创 C语言函数的参数及传递方式

1.形式参数和实际参数1.1形式参数形参出现在被调函数当中,在整个函数体内都可以使用。形参在定义时编译系统并不分配存储空间,只有在调用该函数时才分配内存单元。调用结束内存单元被释放,故形参只有在函数调用时有效,调用结束时不能再使用。1.2实际参数实参出现在主调函数当中,当函数调用时,朱调函数把实参的值传送给被调函数的形参,从而实现函数间的数据传递。传递方式有两种:值传递和地址传

2016-05-08 10:37:40 27899 4

C#socket聊天室

这是用C#写的socket通信的源码,可以直接运行修改

2016-03-22

空空如也

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

TA关注的人

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