自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(32)
  • 资源 (8)
  • 收藏
  • 关注

原创 [LeetCode-69] Sqrt(x)(求解平方根)

Implement int sqrt(int x).Compute and return the square root of x.这道题一看到函数的定义int sqrt(int x)都是int就高兴了,直接二分吧。但是要注意,即使用long long都越界,还要用unsigned long long。最后返回值还要再检查一下。http://blog.csdn.net/

2015-10-29 21:17:33 553

原创 [LeetCode-50] Pow(x, n)(数值的整数次方)

Implement pow(x, n).Subscribe to see which companies asked this question【方法一】:1)最直观容易想到的方法就是用递归方法求n个x的乘积,注意考虑n的正负号,时间复杂度为O(n)double pow(double x, int n){ if(n==0) return 1.0; if(n<0

2015-10-29 20:19:39 4162 1

原创 [LeetCode-66] Plus One

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.【分析】:题意:一个整数按位存储于一个i

2015-10-25 11:02:38 410

原创 [LeetCode-204] Count Primes(0~n 有多少个质数—4种方法求解)

埃拉托色尼筛选法(1)先把1删除(现今数学界1既不是质数也不是合数)(2)读取队列中当前最小的数2,然后把2的倍数删去(3)读取队列中当前最小的数3,然后把3的倍数删去(4)读取队列中当前最小的数5,然后把5的倍数删去(5)如上所述直到需求的范围内所有的数均删除或读取

2015-10-23 15:18:31 2579

原创 [LeetCode-38] Count and Say

The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as

2015-10-23 09:57:08 514

原创 [LeetCode-20] Valid Parentheses(用栈解决配对问题)

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va

2015-10-22 11:25:08 620

原创 [LeetCode-225] Implement Stack using Queues(两个队列实现栈)

Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() -- Return whet

2015-10-21 18:07:39 867

原创 [LeetCode-232] Implement Queue using Stacks(两个栈实现一个队列)

Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front element.empty(

2015-10-21 14:23:34 784

原创 堆栈顺序存储和 free 失败原因分析

*** Error in `./a.out': free(): invalid pointer: 0x09e7c018 ***======= Backtrace: =========/lib/i386-linux-gnu/libc.so.6(+0x767c2)[0xb76307c2]/lib/i386-linux-gnu/libc.so.6(+0x77510)[0xb7631510]./a

2015-10-19 17:20:08 2026

原创 中断服务函数能不能带形参和返回值?

概述从本质上来讲,中断是一种电信号,当设备有某种事件发生时,它就会产生中断,通过总线把电信号发送给中断控制器。如果中断的线是激活的,中断控制器就把电信号发送给处理器的某个特定引脚。处理器于是立即停止自己正在做的事,跳到中断处理程序的入口点,进行中断处理。(1) 硬中断由与系统相连的外设(比如网卡、硬盘)自动产生的。主要是用来通知操作系统系统

2015-10-19 14:30:47 21098

原创 [LeetCode-155] Min Stack(设计一个 min 函数栈)

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get

2015-10-19 10:06:26 618

原创 [LeetCode-58] Length of Last Word(最后一个单词长度)

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is

2015-10-15 14:05:39 2365

原创 [LeetCode-82] Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1-

2015-10-14 08:46:27 489

原创 [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.【分析】从将有序链表中的重复元素删除[

2015-10-13 21:33:48 346

原创 [LeetCode-80] Remove Duplicates from Sorted Array II

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-10-13 21:09:45 356

原创 [LeetCode-26] Remove Duplicates from Sorted Array(移除数组重复元素)

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 in place with

2015-10-13 20:52:25 424

原创 [LeetCode-268] Missing Number(找缺失的数字)

找到数组中缺失数:分以下两种解法:①输入数组是有序数组②输入数组是无序数组。输入的数组是一个无序数组(当缺失添加进输入时,排序后是一个等差数列,公差为1),找到缺失数,题目要求时间复杂度为n,所以想先将数组排序的想法肯定不实际,由题意,大小为n的数组里的所有数都是0 - n之间的数,无需数组,我们首先遍历一遍记录最大、最小值以及实际数组和,用最小值到最大值相加之后得到的期望数组和减去实际数组和,就是缺失的整数。【输入的数组是一个有序数组,找到缺失数,题目要求时间复杂度为n,由题意,大小为n的数组里的所有数都

2015-10-12 17:04:55 866

原创 [LeetCode-258] Add Digits(非负整数各位相加)

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has on

2015-10-11 10:44:14 2142 1

原创 [LeetCode-92] Reverse Linked List II(反转指定区间链表)

【分析】反转链表,但不是从头到尾的反转,给定了一个[m,n]范围,反转指定区间的链表。1 ≤ m ≤ n ≤ length of list.不满足条件的话,返回原链表

2015-10-10 09:41:28 815

原创 Linux Shell 之 Shell 基本控制结构(二)(循环结构)

与其他编程语言类似,Shell支持for循环,和while 循环。1、for 循环for循环一般格式为: for 变量 in 列表docommand1command2...commandNdone列表是一组值(数字、字符串等)组成的序列,每个值通过空格分隔。每循环一次,就将列表中的下一个值赋给变量。in 列表是可选的,如果不用它,for 循环使用命令

2015-10-09 20:00:08 729

原创 [Leetcode-142] Linked List Cycle II(链表有环详细分析)

环的长度是多少?如何找到环中第一个节点(即Linked List Cycle II)?如何将有环的链表变成单链表(解除环)?如何判断两个单链表是否有交点?如何找到第一个相交的节点?

2015-10-09 09:33:42 3660 7

原创 [LeetCode-141] Linked List Cycle(判断链表是否有环)

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?【分析】关于这个问题可以参考http://leonax.net/p/1960/find-circle-in-linked-list/。由于每一个父亲只有可能

2015-10-08 22:33:41 2061 1

原创 [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?【分析】找到链表中点,拆分后,逆转后半个链表,然后两个链表同时顺序遍历一次。不过唯一需要注意的是,当链表长度为奇数,我们需要先将链表中点

2015-10-08 21:46:57 670

原创 [LeetCode-160] Intersection of Two Linked Lists(找到两链表公共交叉点)

Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘

2015-10-07 17:21:16 503

原创 Linux Shell 之 Shell 基本控制结构(一)(if and case)

1、条件分支if 语句通过关系运算符判断表达式的真假来决定执行哪个分支。Shell 有三种 if ... else 语句:if ... fi 语句; if ... else ... fi 语句; if ... elif ... else ... fi 语句。 1) if ... else 语句if ... else 语句的语法:if [ expression ]t

2015-10-06 20:46:55 1924

原创 Linux Shell 之 Shell 数组建立与使用

bash支持一维数组(不支持多维数组),并且没有限定数组的大小。类似与C语言,数组元素的下标由0开始编号。获取数组中的元素要利用下标,下标可以是整数或算术表达式,其值应大于或等于0。1、定义数组在Shell中,用括号来表示数组,数组元素用“空格”符号分割开。定义数组的一般形式为:array_name=(value1 ... valuen)例如:array_name=(val

2015-10-06 17:00:13 669

原创 [LeetCode-172] Factorial Trailing Zeroes(n 阶乘后面有几个0)

Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.【分析】只有2和5相乘才会出现0,其中整十也可以看做是2和5相乘的结果,所以,可以在n之前看看有多少个2以及多少个5就行了,又发

2015-10-06 16:10:32 569

原创 [LeetCode-171] Excel Sheet Column Number(26进制转10进制)

Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ...

2015-10-06 15:57:58 536

原创 [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

2015-10-06 15:45:39 1499

原创 [LeetCode-168] Excel Sheet Column Title(10进制转26进制)

Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB Excel序是

2015-10-06 15:11:19 1362

原创 Linux Shell 之 Shell 打印命令

1、echo 命令 echo是Shell的一个内部指令,用于在屏幕上打印出指定的字符串。命令格式:echo arg您可以使用echo实现更复杂的输出格式控制。显示转义字符"echo "\"It is a test\""结果将是:"It is a test"双引号也可以省略。 显示变量name="OK"echo "$name It is a test"结果将是:OK It is

2015-10-02 10:03:03 5880

原创 Linux Shell 之 Shell 字符串操作

1、引言字符串是shell编程中最常用最有用的数据类型(除了数字和字符串,也没啥其它类型好用了),字符串可以用单引号,也可以用双引号,也可以不用引号。单双引号的区别跟PHP类似。单引号str='this is a string'单引号字符串的限制: 单引号里的任何字符都会原样输出,单引号字符串中的变量是无效的; 单引号字串中不能出现单引号(对单引号使

2015-10-01 21:38:44 717

GP接口函数描述和入参解析

GP接口函数描述和入参解析(持续完善中)。 目前已经涵盖:安全存储相关API,基础API和key相关的API正在完善,后续会补录上去,有需要的同学可以通过CSDN 私信我,单独发你。 函数分析:主要基于optee-os GP相关接口做分析的。

2022-05-04

TCG_TSS_Overview_Common_Structures_v0.9_r03_published

TPM-TSS协议栈

2022-03-20

Linux 设备模型之kobject

kobject_init用来初始化kobject结构,kobject_add用来把kobj加入到设备模型之中。 在实作中,我们先对obj1进行初始化和添加的动作,调用参数里,parent被赋为NULL,表示obj1没有父对象,反映到sysfs里, my_kobj1的目录会出现在/sys下,obj2的父对象设定为obj1,那么my_kobj2的目录会出现在/sys/my_kobj1下面。 前面提到,kobject也提供了引用计数的功能,虽然本质上是利用kref,但也提供了另外的接口供用户使用。 kobject_init_and_add和kobject_init这两个函数被调用后,kobj的引用计数会初始化为1, 所以在module_exit时要记得用kobject_put来释放引用计数。

2015-06-08

Linux下安装神器

Linux下的安装windows exe的神器。

2015-05-22

字符设备LED驱动程序

 所有的驱动程序都应该对应一个具体的设备,这个LED驱动当然设备应该是LED。但是linux将它分成了一类叫做混杂设备。这类设备共享一个主设备号,但次设备号不同所有混杂设备形成一个链表,要访问一个设备时根据次设备号来查找相应的miscdevice。linux中用struct miscdevice来描述一个混杂设备:

2015-04-14

Windows下基于socket多线程并发通信的实现

本文介绍了在Windows 操作系统下基于TCP/IP 协议Socket 套接口的通信机制以及多线程编程知识与技巧,并给出多线程方式实现多用户与服务端(C/S)并发通信模型的详细算法,最后展现了用C++编写的多用户与服务器通信的应用实例并附有程序。 关键词:Windows;套接字;多线程;并发服务器; Socket 是建立在传输层协议(主要是TCP 和UDP)上的一种套接字规范,最初由美国加州Berkley 大学提出,为UNIX 系统开发的网络通信接口,它定义了两台计算机之间通信的规范,socket 屏蔽了底层通信软件和具体操作系统的差异,使得任何两台安装了TCP 协议软件和实现了Socket 规范的计算机之间的通信成为可能,Socket 接口是TCP/IP 网络最为通用的应用接口,也是在Internet 上进行网络程序应用开发最通用的API[1],本文介绍了Socket通信的基本机制以及采用多线程技术实现并发通信的基本原理,并给出实例。

2015-04-07

采温显示存储报警模块

一些常用模块,包括LCD1602显示模块,DS1302模块,DS18B20模块,报警模块,24C02模块,全都是用C语言编写的。全部都通过调试,很方便的。很实用喔。。个人觉得3分并不贵啦,物有所值。。

2013-04-02

matlab基础教学

挺好的一个资源,我从老师那拷贝过来的,与大家分享了,内容很详细!

2011-10-03

空空如也

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

TA关注的人

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