- 博客(52)
- 资源 (8)
- 收藏
- 关注
原创 PHPStudy+eclipse环境配置
一、需要的软件1、Eclipse for PHP Developers2、phpStudy二、配置phpStudy的配置参见链接:点击打开链接eclipse配置1、打开Eclipse,【Window】-【Preferences】,点击PHP下的【PHP Executables】,点击Add添加PHP环境2、在点击PHP下【Servers】
2015-12-29 16:43:40
5255
1
原创 凸包 graham 算法
刚写了一个凸包 graham 算法,mark一下。#include #include #include #include using namespace std;struct Point{ int x,y,xx,yy; Point(int a,int b) { x=a,y=b; } void set(int a,int b) { xx=a,yy=b; }};
2015-12-16 17:21:49
454
原创 密码验证合格程序
描述密码要求: 1.长度超过8位 2.包括大小写字母.数字.其它符号,以上四种至少三种 3.不能有相同长度超2的子串重复 说明:长度超过2的子串知识点字符串,数组运行时间限制0M内存限制0输入一组或多组长度超过2的子符串。每组占一行输出
2015-08-27 18:26:32
1913
原创 公共字串计算
一、题目(来源:点击打开链接)述题目标题:计算两个字符串的最大公共字串的长度,字符不区分大小写详细描述:接口说明原型:int getCommonStrLength(char * pFirstStr, char * pSecondStr);输入参数: char * pFirstStr //第一个字符串 char * pSecondStr//
2015-08-27 14:38:45
549
原创 Performance Log
一、题目 : Performance Log (来源:点击打开链接)描述You are given a txt file, which is performance logs of a single-threaded program.Each line has three columns as follow:[Function Name] [TimeStamp] [
2015-08-21 16:31:29
546
原创 连连看
一、题目: 连连看描述小江最喜欢玩的游戏"天下3"最近推出了连连看的小玩法。玩家可以将2个相同图案的牌子连接起来,连接线不多于3根线段(即最多拐2折),就可以成功将这对牌子消除。如示意图所示,红色,黄色和蓝色的消除都是合法的,因为它们分别需要2个,0个和1个折。而黑色的消除是不合法的,因为这对牌至少需要拐3个折才能连接起来。但是小江并不满足于这个游戏规则,因为他觉得最多
2015-08-21 13:47:11
726
原创 井字棋
一、题目 : 井字棋时间限制:10000ms单点时限:1000ms内存限制:256MB描述小武是井字棋的忠实粉丝,井字棋,又称为井字游戏、井字过三关等,是种纸笔游戏。其具体玩法为:两个玩家,一个打圈(O),一个打叉(X),轮流在3乘3的格上打自己的符号,最先以横、直、斜连成一线则为胜。当9个格子画满,双方均无法取胜时,则为和局。当有玩家取胜或者下成平局后,比赛结束。
2015-08-21 09:41:28
1670
原创 推箱子
一、题目 : 推箱子时间限制:10000ms单点时限:1000ms内存限制:256MB描述推箱子是一款经典游戏。如图所示,灰色格子代表不能通过区域,蓝色方格是箱子,黑色圆形代表玩家,含有圆点的格子代表目标点。规定以下规则:1、一局游戏中只会有一个箱子,一个玩家和一个目标点。2、通过方向键控制玩家移动。3、图中的灰色格子
2015-08-20 20:56:22
770
原创 Rotate List
一、题目要求Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.二、代码实现 ListNode* ro
2015-07-23 21:46:53
322
原创 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
2015-07-20 00:39:18
282
原创 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(
2015-07-20 00:36:46
381
原创 Binary Tree Right Side View
一、题目要求Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tre
2015-07-20 00:34:47
363
原创 Number of 1 Bits
一、题目要求Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representatio
2015-07-20 00:32:58
374
原创 Reverse Bits
一、题目要求Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as
2015-07-20 00:31:07
208
原创 Rotate Array
一、题目要求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].二、代码实现解法1: void rotate(vector& nu
2015-07-20 00:27:37
250
原创 Factorial Trailing Zeroes
一、题目要求Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.二、代码实现int trailingZeroes(int n) { int base=5;
2015-07-20 00:25:17
286
原创 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 -> 1 B -> 2 C
2015-07-20 00:23:51
259
原创 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
2015-07-20 00:22:02
303
原创 Excel Sheet Column Title
一、题目要求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 -
2015-07-20 00:20:12
320
原创 Min Stack
一、题目要求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.
2015-07-20 00:18:32
285
原创 Reverse Words in a String
一、题目要求Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".二、代码实现 void reverseWords(string &s) { if(
2015-07-20 00:16:35
286
原创 Binary Tree Preorder Traversal
一、题目要求Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].二、代码实现 vect
2015-07-20 00:13:18
255
原创 Binary Tree Postorder Traversal
一、题目要求Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].二、代码实现vector p
2015-07-20 00:00:02
228
原创 Single Number
一、题目要求Given an array of integers, every element appears twice except for one. Find that single one.二、代码实现解法1:int singleNumber(vector& nums) { if(nums.size()==1) return nums[0]; ma
2015-07-19 23:56:34
226
原创 Path Sum
一、题目要求Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary t
2015-07-19 23:38:21
227
原创 Balanced Binary Tree
一、题目要求Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node n
2015-07-19 23:36:44
226
原创 Binary Tree Level Order Traversal II
一、题目要求Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#
2015-07-19 23:34:30
229
原创 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.二、代码实现int maxDepth(Tre
2015-07-19 23:32:47
188
原创 Minimum Depth of Binary Tree
一、题目要求Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.二、代码实现int minDepth(Tre
2015-07-19 23:31:21
232
原创 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-07-19 23:29:23
175
原创 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?二、代码实现 int climb
2015-07-19 23:27:20
217
原创 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.二、代码实现 v
2015-07-19 23:25:51
282
原创 Pow(x, n)
一、题目要求Implement pow(x, n).二、代码实现double myPow(double x, int n) { if(n==0) return 1; if(n==1 ||x==0) return x; if(x==0) return x; if(n<0) { x=1/x; n=-n; } // dou
2015-07-19 23:24:19
253
原创 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
2015-07-19 23:22:17
223
原创 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 i
2015-07-19 23:18:28
258
原创 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 "()[]{}"
2015-07-19 23:16:11
180
原创 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
2015-07-19 23:13:24
203
原创 Longest Common Prefix
一、题目要求Write a function to find the longest common prefix string amongst an array of strings.二、代码实现string longestCommonPrefix(vector& strs) { if(strs.empty()) return ""; if(strs.size()==1)
2015-07-19 23:11:32
178
原创 Palindrome Number
一、题目要求Determine whether an integer is a palindrome. Do this without extra space.二、代码实现 int i,len=0,y=x,base=1; if(x<0) return false; if(x-1) return true; while(y) { y=y/10;
2015-07-19 23:09:19
186
原创 String to Integer (atoi)
一、题目要求Implement atoi to convert a string to an integer.Requirements for atoi:The function first discards as many whitespace characters as necessary until the first non-whitespace charact
2015-07-19 23:06:44
276
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人