
Data structure and algorithm
学生症
coder
展开
-
[leetcode]Binary Tree Maximum Path Sum
Binary Tree Maximum Path Sum leetcode 递归原创 2015-10-31 17:35:12 · 623 阅读 · 0 评论 -
POJ1164
#include<iostream>#include<stack>#include<cstring>using namespace std;int R,C;//行列数int rooms[60][60];int color[60][60];//房间染色标记int maxRoomArea=0,roomNum=0;int roomArea;void Dfs(int i,int k){原创 2015-09-30 17:32:46 · 1136 阅读 · 0 评论 -
蓄水池问题
蓄水池问题思路1,从左扫描一遍,从右扫描一遍思路2,两个指针分别从左右扫描#include using namespace std;int getMaxVolume(int arr[],int len){ int pl=0; //int pr=sizeof(arr)/sizeof(arr[0])-1;//arr is a pointer int pr=le原创 2014-12-30 16:28:57 · 1260 阅读 · 0 评论 -
图的遍历
深搜package Lesson1;public class MyDeep { public static void deepTravel(int[][] a, int[] color, int k) { System.out.println(k); color[k] = 1;// 标记为已访问 for (int i = 0; i < a[k].length; i++)原创 2014-10-21 14:57:59 · 570 阅读 · 0 评论 -
POJ 背包
wakeng原创 2014-11-18 22:40:17 · 580 阅读 · 0 评论 -
表达式求值
package bishi;import java.util.HashMap;import java.util.Map;import java.util.Stack;public class MyExpression { public static void calcu(Stack datas, Stack ops) { // 后弹出的放在右边 int b = (Integ原创 2014-11-02 21:15:26 · 521 阅读 · 0 评论 -
分油问题
递归原创 2014-10-22 17:42:14 · 1670 阅读 · 0 评论 -
单词倒置
如"i am a student" 倒置为 "student a am i"原创 2014-11-01 23:39:11 · 665 阅读 · 0 评论 -
Single Number
1、2N+1个数中有一个是不一样的,其他书原创 2014-10-28 14:02:59 · 555 阅读 · 0 评论 -
博弈树
博弈树原创 2014-11-10 23:31:27 · 3780 阅读 · 0 评论 -
井字棋
挖坑原创 2014-11-10 23:54:21 · 880 阅读 · 0 评论 -
概率模拟
测试。。原创 2014-11-02 21:16:09 · 753 阅读 · 0 评论 -
迷宫问题
dfs原创 2014-10-22 16:34:52 · 658 阅读 · 0 评论 -
八皇后问题
试探+回溯原创 2014-10-21 23:32:20 · 493 阅读 · 0 评论 -
POJ2676
#include<iostream>#include<vector>#include<algorithm>#include<cstring>using namespace std;short rowFlags[9][10];//rowFlags[i][num]=1表示在第i行已经放了数字numshort colFlags[9][10];//colFlags[j][num]=1表示在第j列已原创 2015-10-05 15:03:15 · 535 阅读 · 0 评论 -
[leetcode]Maximum Subarray
leetcode Maximum Subarray原创 2015-10-09 14:34:26 · 792 阅读 · 0 评论 -
[leetcode] Search a 2D Matrix
search a 2D Matrix原创 2015-10-10 16:59:16 · 450 阅读 · 0 评论 -
[leetcode] Construct Binary Tree from Preorder and Inorder Traversal
Construct Binary Tree from Preorder and Inorder Traversalclass Solution {public: TreeNode *buildTreebyIndex(vector &preorder,int preBegin,int preEnd,vector &inorder,int inBegin,int inEn原创 2014-07-21 01:18:08 · 552 阅读 · 0 评论 -
POJ3624
0-1背包,动态规划原创 2015-10-28 14:29:33 · 1136 阅读 · 0 评论 -
[leetcode]Decode Ways
leetcode Decode Ways原创 2015-10-14 16:35:28 · 494 阅读 · 0 评论 -
[leetcode]Find Peak Element
leetcode Find Peak Element原创 2015-10-14 14:14:21 · 422 阅读 · 0 评论 -
[leetcode]Find Minimum in Rotated Sorted Array II
leetcode Find Minimum in Rotated Sorted Array II原创 2015-10-14 13:26:34 · 729 阅读 · 0 评论 -
[leetcode]Find Minimum in Rotated Sorted Array
leetcode find mininum in rotated sorted array原创 2015-10-14 12:58:26 · 507 阅读 · 0 评论 -
[leetcode]Median of Two Sorted Arrays
leetcode Median of Two Sorted Arrays原创 2015-10-12 11:13:07 · 696 阅读 · 0 评论 -
POJ3278 Catch That Cow
POJ3278 Catch That Cow原创 2015-10-13 09:59:49 · 547 阅读 · 0 评论 -
[leetcode]Combination Sum II
leetcode Combination sum原创 2015-10-12 17:24:59 · 529 阅读 · 0 评论 -
[leetcode]Combination Sum
leetcode combination sum原创 2015-10-12 16:43:43 · 500 阅读 · 0 评论 -
[leetcode]Sort Colors
荷兰国旗问题 Sort Colors原创 2015-10-12 11:33:12 · 612 阅读 · 0 评论 -
[leetcode]Number of Islands
leetcode Number of Islands原创 2015-10-12 14:55:42 · 489 阅读 · 0 评论 -
[leetcode]Sliding Window Maximum
双端队列 maxSlidingWindow deque原创 2015-10-26 10:40:11 · 676 阅读 · 0 评论 -
最短路径
单源最短路径边权不等,原创 2014-10-21 22:37:08 · 808 阅读 · 0 评论 -
Josephus Problem
Josephus Problem:解法1、模拟法,使用xun'hu原创 2014-08-10 22:55:01 · 816 阅读 · 0 评论 -
Longest Increasing Subsequence
Longest Increasing Subsequence原创 2014-08-10 11:39:52 · 508 阅读 · 0 评论 -
[leetcode] Insertion Sort List
#include "iostream"using namespace std;/**Definition for singly-linked list.*/struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {原创 2014-05-07 15:11:00 · 585 阅读 · 0 评论 -
[leetcode] Reverse Words in a String
#include "iostream"using namespace std;class Solution {public: void reverseWords(string &s) { int len=(int)s.length()-1;//显示转换unsigned long to int string res=原创 2014-05-11 02:09:46 · 578 阅读 · 0 评论 -
[leetcode] Word Ladder
#include #include //mac os下引用unordered_set,散列容器#include #include using namespace std;class Solution {public: int ladderLength(string start, string end, unordered_set &dict) {原创 2014-05-12 01:26:17 · 865 阅读 · 0 评论 -
[leetcode] Word Search
class Solution {public: bool exist(vector > &board, string word) { if (word.size()==0) { return true;//空串返回true } int row=board.size(); int co原创 2014-05-20 00:22:57 · 595 阅读 · 0 评论 -
ThoughtWorks FizzBuzzWhizz
#include #include using namespace std;int main(){ cout<<"pls input 3 numbers a,b,c (0<a,b,c<10 and a!=b!=c):"<<endl; int x1,x2,x3; cin>>x1>>x2>>x3; string str1,str2,str3; ost原创 2014-05-05 16:02:18 · 599 阅读 · 0 评论 -
数据结构 算法 在线演示
http://sjjg.js.zwu.edu.cn/SFXX/sf1/sfys.html原创 2013-12-02 11:07:27 · 2620 阅读 · 1 评论 -
HDoj第几天
#include#define LeapYear(year) ((year%4==0&&year%100!=0)||year%400==0)/** 把判断闰年的算法写成一个宏,是闰年返回1,否则返回0。*/int main(){ int year,month,day,i,sum; int ly[2][13]= { {0,31,28,31,30,3原创 2013-04-06 16:24:52 · 694 阅读 · 0 评论