- 博客(18)
- 资源 (1)
- 收藏
- 关注
原创 getopt、getopt_long和getopt_long_only解析命令行参数
一:posix约定: 下面是POSIX标准中关于程序名、参数的约定: 程序名不宜少于2个字符且不多于9个字符; 程序名应只包含小写字母和阿拉伯数字; 选项名应该是单字符或单数字,且以短横 ‘-’ 为前綴; 多个不需要选项参数的选项,可以合并。(譬如:foo -a -b -c ----> fo
2015-07-30 21:44:03 1755
原创 Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by thecharacter '.'.You may assume that there will be only one unique solution.
2015-07-28 22:03:16 478
原创 Python深入:编码问题总结
一:字符编码简介 1:ASCII 最初的计算机的使用是在美国,所用到的字符也就是现在键盘上的一些符号和少数儿个特殊的符号,一个字节所就能足以容纳所有的这些字符,实际上表示这些字符的字节最高位都为0,也就是说这些字节都在0到127之间,如字符a对应数字97。这套编码规则被称为ASCII(美国标准信息交换码)。 2:GBK、GB2312
2015-07-26 16:15:55 19695 1
原创 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 t
2015-07-20 12:45:13 490
原创 Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 01 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 i
2015-07-19 22:48:59 415
原创 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
2015-07-16 18:28:49 435
原创 Divide Two Integers
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT. 思路:实现两个整数的除法,不能使用乘法,除法和移位操作。首先想到的是减法,但是减法速度太慢,比如10000000/1,总共需要10000000次减法,所以不适用。
2015-07-16 12:41:18 444
原创 Python基础:28正则表达式
一:概述 正则表达式(RE)为高级文本模式匹配,以及搜索-替代等功能提供了基础。正则表达式(RE)是一些由字符和特殊符号组成的字符串,它们能匹配多个字符串。Python通过标准库的re模块支持正则表达式。 在Python中,有两种主要方法完成模式匹配:搜索(searching)和匹配(matching)。搜索是在字符串任意部分中查找匹配的模式;而匹配是指判断一个
2015-07-15 23:26:28 781
原创 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 wi
2015-07-15 16:48:19 715
原创 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 asit is.
2015-07-14 22:29:39 622
原创 Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 思路:要快速找到k个元素中的最小值,使用堆这种数据结构。找到最小值后,还需要知道该最小值出自哪个链表,因此,堆中还需记录每个节点来自哪个链表。调整堆的时间复杂度为O(logk),所以总体时间复杂
2015-07-14 17:50:25 393
原创 Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))","(()())", "(())()", "()(())", "()()()"
2015-07-14 11:32:24 480
原创 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 end points of line i is at (i, ai) and (i, 0). Find two
2015-07-13 10:50:12 462
原创 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 i
2015-07-12 21:35:30 503
原创 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)). 思路:首先注意一点,这里所谓的”the me
2015-07-12 14:38:36 429
原创 Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3.
2015-07-12 10:14:23 501
原创 Longest Valid Parentheses
Given a string containing just the characters '(' and ')',find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",which
2015-07-10 10:54:11 487
原创 LInux下编译发生的libc相关错误
在某主机上编译程序,发生有找不到libc的问题,自己写了个简单的hello world程序,编译也失败,报错如下:# gcc -o 1 1.c/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../libc.so when searching for -lc/usr/bin
2015-07-06 17:23:29 7866
柔性数组成员
2018-09-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人