自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

hsjshichengxuyuan的博客

我说我以前把这些发在QQ空间你敢信?

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

原创 一个简单的组合控件示例

前言我们要写一个自定义组合控件,放在MainActivity中,MainActivity的布局文件是Android Studio自动生成,名字是activity_main.xml我们要写的自定义组合控件由3个TextView组成(叫它们 num1,num2, num3 吧),分别显示三个数字。 规律是 num1显示 a,mum2和num3 就显示 (a+1)和(a+2)。根据需求,我们需要给自

2016-08-15 01:03:06 661

转载 文章标题

关于Android中图片资源文件夹的一些理解简单总结一下:使用上没有任何区别,但是用mipmap系统会在缩放上提供一定的性能优化。1. DPI这个概念DPI,全称 dots per inch,意为每英寸的直线上像素点的数量。dpi越高,屏幕的画面越清晰,画质越细腻。

2016-07-13 00:34:23 334

原创 【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 of h-index on Wikipedia: "A

2015-09-04 21:54:30 478

原创 【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.Note:Your algorithm shoul

2015-08-25 09:12:53 318

原创 【leetCode】Maximum Gap

Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contains less than 2 elements

2015-08-24 17:59:37 292

原创 Binary Tree Paths

Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]思路很简单

2015-08-16 14:14:54 336

原创 【练习题】硬币组合

题目:如果我们有面值为1元、3元和5元的硬币若干枚,如何用最少的硬币凑够指定金额?     函数:    /**     target : 给定的金额;    coins : 存放了所有硬币面额的vector,这里是{1,3,5};    **/     int getTheLeastCoinNum(int target,vector& coins);    

2015-08-09 16:29:05 989

原创 【leetCode】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.需要注意的是,空树也

2015-08-07 09:51:58 301

原创 【leetCode】Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.貌似没啥好讲的~直接上代码吧。/** * Definiti

2015-08-07 09:35:28 239

原创 【leetCode】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-08-04 20:04:33 321

原创 【leetCode】Lowest Common Ancestor of a Binary Tree

Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes

2015-08-04 14:47:42 394

原创 【练习题】25.找出N个数之和等于M

/* 题目: 给定一个target,和一个"有序"数组ra。 要求: 从ra中挑选length2个数,使得它们之和等于target; 说明: length2个数中可以出现重复 例子: 如 a+b+c = 31,a/b/c都来自于[1,3,5,7,9,11,13,15]。 则*

2015-08-04 09:39:21 1647

原创 【练习题】27.2-35进制数转换为10进制数

/*输入一个2-35进制数字的字符串(字母一律大写),输出这个数值对应的十进制结果,达到进制转换目的,范围:0-0xFFFFFFFF。*/#pragma once#include #include using namespace std;//工具函数,取得字符C对应的数字int getNum(const char& c,const char* array,int le

2015-08-04 09:34:39 1181

原创 【leetCode】Delete Node In A Linked List

题目:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node wit

2015-08-04 09:08:45 492

原创 【一个小实验】找出两个数组中相同的元素

搬运自洒家的QQ空间(不要问我问什么用空间,懒就一个字......),转载请注明出处。 在实际中,我们经常需要找出两个数组A和B中相同的元素(事实上,在面试中或者做题的时候大家也应该遇到过很多这样的题目)。        通常的做法自然是两层for循环,从A中取一个元素α,在B中遍历查找这个α。设A/B的长度分别为N和M。那这个算法的时间复杂度将达到N*M。如果N和M都很大的情况下(比

2015-08-02 16:31:01 4920

原创 【练习题】26.字符串压缩

题目:给定一个字符串,实现一个函数,按下述方式输出字符串:1、如果此字符的下一个字符和此字符不一样,原样输出此字符;2、如果此字符的下一个字符和此字符一样,先输出此字符,再输出此字符连续出现的次数(次数不大于9)。例如,字符串ABBCCCDEDFFF,输出的结果为AB2C3DEDF3。 不用考虑溢出问题,不能使用任何I/O函数。

2015-08-02 10:26:05 1153

原创 【leetCode】Search a 2D Matrix

题目: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 from left to right.The first integer of e

2015-08-02 10:07:58 323

原创 【leetCode】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.Note:You ma

2015-08-02 09:55:10 303

原创 【练习题】28.字符串转换

题目:将输入的字符串(字符串仅包含小写字母‘a’到‘z’)按照如下规则,循环转换后输出:  a->b,b->c,…,y->z,z->a;说明:1、若输入的字符串连续出现两个字母相同时,后一个字母需要连续转换2次。例如:aa 转换为 bc,zz 转换为 ab;2、当连续相同字母超过两个时,第三个出现的字母按第一次出现算。函数:void convert(char *

2015-08-01 16:15:26 572

原创 【一个小实验】排序效率比较

最近参加内推,四轮技术面里头有三轮都问到了排序(各种排序)。无奈表示我还没复习数据结构和算法部分.....今天正好有空,把几个被问到的排序算法都写出来比较下到底哪个更快,快多少。        需要注意的是:两路归并排序这个O(NlogN)时间复杂度的我没(Bu)写(Hui)。原因在快速排序里面已经展现了。其次,每次参与的数组均由随机函数生成。        先说结论:

2015-08-01 16:07:58 450

原创 【leetCode】Swap Nodes in Pairs

题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant s

2015-08-01 16:06:44 279

原创 【leetCode】Product of Array Except Self

题目: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 di

2015-08-01 16:03:23 368

原创 【leetCode】Sliding Window Maximum【求高人解释】

class Solution {public: vector maxSlidingWindow(vector& nums, int k) { int max = 0; vector r;//结果vector vector::size_type length = nums.size(); //如果传入数组为空 if (nums.size() == 0 || k<1)

2015-07-31 14:55:14 370

空空如也

空空如也

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

TA关注的人

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