- 博客(13)
- 资源 (4)
- 问答 (2)
- 收藏
- 关注
原创 Pascal's Triangle II
Given an index k, return the kth row of the Pascal’s triangle.For example, given k = 3, Return [1,3,3,1].Note: Could you optimize your algorithm to use only O(k) extra space?int* getRow(int rowIndex,
2015-09-25 10:29:29 421
原创 Pascal's Triangle
Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]int** generate(int numRows, int
2015-09-24 22:32:58 398
原创 杨辉三角序列的生成
void Pascal(int n) {if (n == 0) return;int** num = (int**)malloc(sizeof(int*)*n);for (int i = 0; i < n; i++) num[i] = (int*)malloc(sizeof(int)*n);for (int i = 0; i < n; i++){ for (int j
2015-09-21 21:28:04 475
原创 类对象的赋值和复制
对象的赋值可以采用重载运算符的方法实现: 对象名1 = 对象名2;对象的复制可以采用复制构造函数的方法实现: (1)类名 对象2(对象1) (2)类名 对象2 = 对象1 这两种方法调用的都是复制构造函数而不是构造函数,故需要提前声明复制构造函数;若没有声明复制构造函数,则这两种方法在编译时均能通过,但也没有调用构造函数,程序运行结束时却会调用析构函数。class myClass { p
2015-09-15 23:31:52 1784
原创 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.char* multiply(char* num1, char* num2) {//获取字符
2015-09-15 16:50:54 263
原创 Single Number III
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given nums = [1,
2015-09-13 16:36:59 242
原创 Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using ex
2015-09-13 11:10:01 350
原创 Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra me
2015-09-13 11:08:48 250
原创 House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses
2015-09-07 21:25:51 68
原创 求两个字符串的最长公共子串的长度
int func(char* query, char* text) {if (query == NULL || text == NULL) return 0;int len1 = strlen(query);int len2 = strlen(text);int sum = 0;int count = 0;for (int start = 0; start < len2; start
2015-09-07 20:36:58 632
原创 Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you are
2015-09-05 22:21:58 304
原创 Ugly Number II
Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly
2015-09-05 18:46:26 300
原创 Ugly Number
Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it in
2015-09-05 16:39:27 310
Convert To Renex
2013-11-14
注释掉printf语句程序出现段错误
2015-12-25
攻击者能够欺骗 DNS,如何解决?
2014-12-12
TA创建的收藏夹 TA关注的收藏夹
TA关注的人