- 博客(15)
- 收藏
- 关注
原创 Leetcode-Explore-"Linked List"
1.Remove Linked List Elementclass Solution {/** Iterative solution * */public: ListNode* removeElements(ListNode* head, int val) { if(head==NULL) return NULL; while(head->...
2018-11-13 10:50:37
164
原创 LeetCode-Explore-"Binary Tree"
1.Preorder,Inorder,Postorderclass Solution {//recursive solution//preorderprivate: void preOrder(TreeNode* cur,vector<int> &res){ if(cur==NULL) return; res...
2018-11-12 11:32:19
340
原创 LeetCode-Explore-"Queue & Stack"
1.Walls and Gates要注意对超出范围的点的处理class Solution {public: void wallsAndGates(vector<vector<int>>& rooms) { if(rooms.size()==0) return; int row=rooms.s...
2018-11-12 10:57:25
145
原创 leetcode-explore-Queue&Stack
1.Number of islandsclass Solution {//BFSpublic: int numIslands(vector<vector<char>>& grid) { if(grid.size()==0) return 0; int numisland=0; ...
2018-10-30 11:53:54
258
原创 leetcode-easy前50题整理
7.reverse intergerclass Solution {//beat 97.87%//但是太繁琐了public: int reverse(int x) { int flag,number; if(x==-pow(2,31)) return 0; if(x>...
2018-10-12 17:12:33
703
原创 MingoLearnJava
斯坦福Java网课的karel找中点的题今天写了会居然写出了,思路还是昨天做梦的时候想到的,我真是服了,贴一下免的忘了/* * File: MidpointFindingKarel.java * ------------------------------- * When you finish writing it, the MidpointFindingKarel class sho...
2018-10-10 20:28:03
124
原创 USACO第二章
castle:染色,对访问过的房间做标记,bfs函数中对没有墙的那一面继续搜索。ordered fractions:列出所有分数,但只输出和前一个不一样的分数。sorting a three valued sequence:先交换1部分里的2和2部分里的1,1部分里的3和3部分里的1,再换那种要换两次才到位的。healthy holsteins:想要检查任意个数是否满足要求的深搜。...
2018-10-01 11:37:22
135
原创 USACO第一章
Friday:只有闰年二月的天数是有变化的,所以先把十二个月的天数存在一个数组里,直接调用。beads:对于环形的项链,可以用两条线性的代替,这样扫描长度为N时,效果和扫描环形是一样的;如果第i个是红色的,那么到第i个连续的红色的数目等于到第i-1个红色的数目加一。然后从左从右取最大的相加。milking cows:用数组连续的1表示持续时间。transformations:二元数组找...
2018-09-30 22:13:17
145
原创 数据结构第二章习题
2.15//2018年8月17日 练习2.15void stick(linklist &ha, linklist &hb, linklist &hc){ if (m < n) { pa = ha->next; while (pa->next != null) pa = pa->next; pa->next = ...
2018-08-17 21:44:30
1545
原创 c++primer 第七章习题答案
7.7//2018年8月17日 练习7.7Sales_data total;if (read(cin, total)) { sales_data trans; while (read(cin, trans)) { if (total.isbn() = trans.isbn()) { total.combine(trans); } else { print(co...
2018-08-17 14:05:30
1130
原创 c++primer6.3节练习
6.33#include "stdafx.h"#include "iostream"#include "stddef.h"#include "string"#include<vector>using namespace std;//2018_7_29,递归主要思想:返回的还是原先的vector,但是迭代器加一。vector<int> output(con
2018-07-29 16:06:04
192
原创 C++primer习题6.2节练习
练习6.10#include "stdafx.h"#include "iostream"#include "stddef.h"#include<vector>using namespace std;//2018_7_26 void exchange(int *p, int *q);int main(){ cout << "please enter t...
2018-07-26 22:13:34
221
原创 计算机原理组成—第一章习题
一.选择7.完整的计算机系统应该包括 配套的硬件设备和软件系统12.用户与计算机通信的界面是 外部设备27.计算机中 控制单元 负责指令译码29.80286是个人计算机中的 CPU 器件(是intel的一款芯片)38.控制器 可以区分存储单元中存放的是指令还是数据39.存放欲执行指令的寄存器是 IR41.在CPU中跟踪指令后继地址的寄存器是 PC二.填空2.计算...
2018-07-26 14:33:28
1595
原创 数据结构第一章习题
1.16#include "stdafx.h"#include "iostream"//2018_7_25,假设全是整数了,可以改数据类型using namespace std;int main(){ size_t a, b, c; cout << "please enter three number" << endl; cin >> a ..
2018-07-25 16:46:08
1283
原创 C++primer习题6.1节练习
练习6.2(a)错误,函数类型是int,但是返回值为string(b)错误,应该为int f2(int i)(c)错误,两个形参相同了(d)错误,少了大括号练习6.4// ConsoleApplication2.cpp: 定义控制台应用程序的入口点。////练习6.4_2018_7_24#include "stdafx.h"#include "iostream"...
2018-07-24 14:37:13
443
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人