- 博客(42)
- 资源 (36)
- 问答 (1)
- 收藏
- 关注
原创 LeetCode(48)Rotate Image
题目You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up: Could you do this in-place?分析本地使得二维矩阵,旋转90角度。通过实际数据分析,通过两个步骤的元素交换可实现目标:按照主对角线,将对称元素交换按照
2015-08-31 20:49:30 2761
原创 LeetCode(47)Permutations II
题目Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1].分析用上一
2015-08-31 20:15:49 483
原创 LeetCode(46)Permutations
题目Given a collection of numbers, return all possible permutations.For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].分析求给定向量数组所有元素的全排列问题。我们
2015-08-31 20:07:48 2442
转载 Unix网络编程 — 头文件解析
1.1. < sys/types.h >primitive system data types(包含很多类型重定义,如pid_t、int8_t等)1.2. < sys/socket.h >//与套接字相关的函数声明和结构体定义,如socket()、bind()、connect()及struct sockaddr的定义等int setsockopt(int s,int level,int o
2015-08-31 17:28:56 1193
原创 LeetCode(43)Multiply Strings
题目Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.分析计算两个字符串表示的非负大整数的乘积,结果仍然用字符串表示。我们都熟悉笔算的整数乘积
2015-08-28 17:42:02 4197
转载 C++动态申请内存 new T()与new T[]的区别
new与delete我们知道,new和delete运算符是用于动态分配和撤销内存的运算符。new的用法开辟单变量地址空间; i. 如 new int ; 指开辟一个存放数组的存储空间,返回一个指向该存储空间的地址。int *a = new int 即为将一个int类型的地址赋值给整型指针a。 ii. int *a = new int(5); 作用同上,同时将首地址处内容赋值为5
2015-08-26 20:01:35 2273
原创 LeetCode(41)First Missing Positive
题目Given an unsorted integer array, find the first missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant space.
2015-08-26 17:31:12 763
原创 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 “one 2, t
2015-08-26 11:14:38 4519
原创 LeetCode(36)Valid Sudoku
题目Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’. A partially filled sudoku wh
2015-08-25 20:40:50 3204
原创 LeetCode(33)Search in Rotated Sorted Array
题目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 target value to search. If found in the array return its ind
2015-08-25 17:25:01 733 1
原创 LeetCode(30) Substring with Concatenation of All Words
题目You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and w
2015-08-24 20:51:05 3074
原创 LeetCode(29)Divide Two Integers
题目Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.分析题目要求不用 * / %三种运算符的条件下,求得两个int类型整数的商。方法一:很明显的,我们可以用求和累计的方法,求得商,但是该方法测试会出现TLE;参考博客提出解决办法:
2015-08-24 19:51:50 666
原创 LeetCode(6) ZigZag Conversion
题目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) And then read line by l
2015-08-23 17:29:34 658
原创 LeetCode(4)Median of Two Sorted Arrays
题目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)).分析给定两个有序序列,要求两个序列综合后的中位数。关键:
2015-08-22 20:35:01 1840
原创 LeetCode(88)Merge Sorted Array
题目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 + n) to hold addition
2015-08-20 17:33:59 2545
原创 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-08-20 11:40:51 1492
原创 LeetCode(70) Climbing Stairs
题目You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?分析这个题目是一个计算n层阶梯情况下,走到顶端的路径种数(要求每次只能
2015-08-19 21:54:20 3811
原创 LeetCode(67) Add Binary
题目Given two binary strings, return their sum (also a binary string).For example, a = “11” b = “1” Return “100”.分析一个简单的字符串相加,该题目要注意两点:字符位的求和计算,必须转换为整型,即: 如下利用‘0’字符作为中间转换,才得到正确结果。int temp = (a[i]-'
2015-08-19 20:58:22 2291
原创 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.分析该题目要求:将一整数按位存储在vector中,对其
2015-08-18 15:38:10 1410
原创 LeetCode(35) Search Insert Position
题目Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Her
2015-08-17 16:28:53 892
原创 LeetCode(34)Search for a Range
题目Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the target is not found in the
2015-08-17 16:03:43 900
原创 LeetCode(237)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 with value 3,
2015-08-15 21:32:23 1419
原创 LeetCode(59)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 defined
2015-08-15 21:08:47 551
原创 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 alway
2015-08-15 20:47:19 586
原创 LeetCode(171) Excel Sheet Column Number
题目Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> 28 ..
2015-08-13 21:38:16 904
原创 LeetCode(31) Next Permutation
题目Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible or
2015-08-13 16:12:05 2215
原创 LeetCode(28)Implement strStr()
题目Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02): The signature of the function had been updated to ret
2015-08-12 17:36:36 696
原创 LeetCode(27)Remove Element
题目Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn’t matter what you leave beyond the new length.分析这是一道很简
2015-08-12 16:50:06 2208
原创 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 co
2015-08-10 20:54:32 584
原创 LeetCode(25)Reverse Nodes in k-Group
题目Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.Yo
2015-08-10 20:16:51 694
原创 LeetCode(24) 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 space. You may
2015-08-10 19:24:07 631
原创 LeetCode(21)Merge Two Sorted Lists
题目Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.分析数据结构与算法的链表章节的典型实例,将两个有序链表合成一个,保持其有序的性质。AC代码/** * Defini
2015-08-10 16:23:33 742
原创 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 valid but
2015-08-09 16:43:00 670
原创 LeetCode(18)4Sum
题目Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: Elements in a qu
2015-08-08 18:12:47 1062
原创 LeetCode(19) Remove Nth Node From End of List
题目Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked list
2015-08-08 16:38:49 680
原创 LeetCode (17)Letter Combinations of a Phone Number
题目Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit string “23”
2015-08-07 21:07:51 900
原创 LeetCode(16)3Sum Closest
题目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 exactl
2015-08-07 17:29:56 1017
原创 LeetCode(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
2015-08-06 16:40:30 1040
原创 LeetCode(14)Longest Common Prefix
题目Write a function to find the longest common prefix string amongst an array of strings.分析该题目是求一个字符串容器中所有字符串的最长公共前缀。AC代码class Solution {public: string longestCommonPrefix(vector<string>& strs) {
2015-08-06 15:22:39 702
原创 LeetCode(13) Roman to Integer
题目Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.分析这个题目是上一题的变形,要求将给定的罗马序列数字转换为对应的整数。 了解罗马数字与整数的对应关系: 对应举例如下: AC代码class Solution{public
2015-08-05 21:15:02 925
适配器模式(Adepter)C#实现及案例
2013-02-04
各种排序的C++算法实现(插入排序、合并排序、堆排序、快速排序)
2013-01-29
java+jsp+tomcat学生管理系统
2013-01-01
java 绘图板程序
2012-12-31
C++ MFC实现飞机大战游戏
2012-12-04
C语言桌面万年历
2012-12-04
Linux聊天室 -- select && 多线程实现
2015-12-22
Windows下Lex与Yacc配置必备工具
2015-01-22
MinGW开发工具
2015-01-09
lex与Yacc所需flex.exe bison.exe
2015-01-09
Web服务器的java实现
2013-02-15
Ubuntu 15.04 qtcreator打不开,请问有人遇到过吗?
2015-10-16
TA创建的收藏夹 TA关注的收藏夹
TA关注的人