上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 37 下一页

2014年5月11日

hackerrank---Find a string

摘要: 题目链接在字符串a中查找字符串b出现的次数...貌似不可以用a.count()附上代码:1 a = raw_input().strip()2 b = raw_input().strip()3 cnt = 0;4 for i in xrange(len(a)):5 cnt += 1 if a.... 阅读全文

posted @ 2014-05-11 16:53 Stomach_ache 阅读(172) 评论(0) 推荐(0)

hackerrank---List Comprehensions

摘要: 题目链接刷刷Python基本功...列表解析附上代码:1 x = int(input())2 y = int(input())3 z = int(input())4 n = int(input())5 print [[i, j, k] for i in xrange(x+1) for j in xr... 阅读全文

posted @ 2014-05-11 16:29 Stomach_ache 阅读(199) 评论(0) 推荐(0)

2014年5月10日

LeetCode --- Plus One

摘要: 题目链接题意:给出一个以数组形式表示的数, 求该数加1后的结果,同样以数组形式返回。附上代码: 1 class Solution { 2 public: 3 vector plusOne(vector &digits) { 4 unsigned int len = digit... 阅读全文

posted @ 2014-05-10 11:14 Stomach_ache 阅读(148) 评论(0) 推荐(0)

2014年5月9日

Vim学习与总结

摘要: 1. :w 后面可以加文件名2. 使用hjkl 来移动光标,当然你也可以使用箭头。j就是向下的箭头,k是向上,h向左, l向右3. :help → 显示相关命令的帮助。你也可以就输入:help而不跟命令。(退出帮助需要输入:q)4. cw替换从光标开始到一个单词结束的字符, cc替换光标所在... 阅读全文

posted @ 2014-05-09 17:03 Stomach_ache 阅读(181) 评论(0) 推荐(0)

LeetCode --- Pascal's Triangle II

摘要: 题目链接题意:在杨辉三角中,给定整数k,输出第k行。附上代码: 1 class Solution { 2 public: 3 vector getRow(int rowIndex) { 4 vector ans(rowIndex+1); 5 // 注意第0行为... 阅读全文

posted @ 2014-05-09 12:24 Stomach_ache 阅读(114) 评论(0) 推荐(0)

2014年5月8日

LeetCode --- Gray Code

摘要: 题目链接一道关于格雷码的题目, 给出n, 输出n位的格雷码。 关于格雷码的详细说明和计算方法请右键:Wiki附上代码: 1 class Solution { 2 public: 3 vector grayCode(int n) { 4 vector ans(1); 5 ... 阅读全文

posted @ 2014-05-08 18:50 Stomach_ache 阅读(123) 评论(0) 推荐(0)

LeetCode --- Two Sum

摘要: 题目链接附上代码: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 class Solution { 7 public: 8 vector twoSum(vector &numbers, int target) ... 阅读全文

posted @ 2014-05-08 11:33 Stomach_ache 阅读(82) 评论(0) 推荐(0)

LeetCode --- Pascal's Triangle

摘要: 题目链接杨辉三角附上代码: 1 class Solution { 2 public: 3 vector > generate(int numRows) { 4 vector > ans(numRows); 5 for (int i = 0; i 0) {11... 阅读全文

posted @ 2014-05-08 11:28 Stomach_ache 阅读(87) 评论(0) 推荐(0)

LeetCode -- Remove Duplicates from Sorted List

摘要: 题目链接简单题,就是从单链表中删除重复元素。附上代码: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * L... 阅读全文

posted @ 2014-05-08 10:44 Stomach_ache 阅读(110) 评论(0) 推荐(0)

LeetCode --Binary Tree Level Order Traversal II

摘要: 题目链接在这题各种RE和WA。 方法上就是BFS, 还是基础不扎实的原因,很明显的一点就是这里使用二维vector, 开始的时候我竟然没有给ans分配空间,然后直接push_back, 导致RE到死。这点是必须引起注意的!附上代码: 1 /** 2 * Definition for binary ... 阅读全文

posted @ 2014-05-08 10:28 Stomach_ache 阅读(191) 评论(0) 推荐(0)

上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 37 下一页

导航