随笔分类 -  Algorithm

ACM、Leetcode、Power8算法挑战赛
摘要:排序引论 选择排序 “一种最简单的排序算法”——《算法(第4版)》 C++代码实现 c++ include include include using namespace std; //选择排序 template void selectionSort(vector &v) { vector::ite 阅读全文
posted @ 2018-09-28 22:16 健康平安快乐 阅读(249) 评论(0) 推荐(0) 编辑
摘要:分枝定界法解0/1背包问题 关键词 :分支定界、0 1背包 分枝定界法简介 分枝定界法按照树形结构来组织解空间,展开节点后,有两种策略: 策略一、把节点加入 FIFO 队列当中; 策略二、把节点加入到堆中,按照最小消耗或者最大消耗来选择下一个展开节点 。 感悟 分枝定界法是一类能确保搜索到全部可行解 阅读全文
posted @ 2018-09-08 16:26 健康平安快乐 阅读(964) 评论(2) 推荐(0) 编辑
摘要:八数码问题 利用启发式搜索,找出以下问题的最优解。 阅读全文
posted @ 2017-11-15 09:44 健康平安快乐 阅读(395) 评论(0) 推荐(0) 编辑
摘要:问题描述 Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more lette 阅读全文
posted @ 2016-09-07 12:28 健康平安快乐 阅读(152) 评论(0) 推荐(0) 编辑
摘要:347. Top K Frequent Elements Given a non empty array of integers, return the k most frequent elements. For example, Given [1,1,1,2,2,3] and k = 2, ret 阅读全文
posted @ 2016-09-07 12:23 健康平安快乐 阅读(144) 评论(0) 推荐(0) 编辑
摘要:215. Kth Largest Element in an Array Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, n 阅读全文
posted @ 2016-09-07 12:21 健康平安快乐 阅读(120) 评论(0) 推荐(0) 编辑
摘要:Given a string, find the first non repeating character in it and return it's index. If it doesn't exist, return 1. Examples: Note: You may assume the 阅读全文
posted @ 2016-08-22 00:52 健康平安快乐 阅读(160) 评论(0) 推荐(0) 编辑
摘要:53. Maximum Subarray Difficulty: Medium Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For e 阅读全文
posted @ 2016-07-31 23:33 健康平安快乐 阅读(439) 评论(0) 推荐(0) 编辑
摘要:题目描述 Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given t 阅读全文
posted @ 2016-06-22 07:12 健康平安快乐 阅读(164) 评论(0) 推荐(0) 编辑
摘要:题目 Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty sp 阅读全文
posted @ 2016-06-21 07:57 健康平安快乐 阅读(163) 评论(0) 推荐(0) 编辑
摘要:题目 55. 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 repr 阅读全文
posted @ 2016-06-21 07:48 健康平安快乐 阅读(163) 评论(0) 推荐(0) 编辑
摘要:题目 Given a m x n grid filled with non negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its pat 阅读全文
posted @ 2016-06-20 08:38 健康平安快乐 阅读(162) 评论(0) 推荐(0) 编辑
摘要:题目 Given a string s and a dictionary of words dict, determine if s can be segmented into a space separated sequence of one or more dictionary words. F 阅读全文
posted @ 2016-06-18 14:23 健康平安快乐 阅读(193) 评论(0) 推荐(0) 编辑
摘要:题目 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 阅读全文
posted @ 2016-06-17 11:08 健康平安快乐 阅读(228) 评论(0) 推荐(0) 编辑
摘要:88. Merge Sorted Array Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has 阅读全文
posted @ 2016-03-09 12:21 健康平安快乐 阅读(169) 评论(0) 推荐(0) 编辑
摘要:第六期Power8大赛 1.1 比赛题目 题目: 计算两个集合的差集; 详细说明: 分别有集合A和B两个大数集合,求解集合A与B的差集(A中有,但B中无的元素),并将结果保存在集合C中,要求集合C中的元素升序。 输入为两个文件,分别为A.txt,B.txt,一行一个值,并且是无序的。结果输出到C.t 阅读全文
posted @ 2016-02-02 19:23 健康平安快乐 阅读(2785) 评论(1) 推荐(0) 编辑
摘要:C++11 feature version#include #include #include using namespace std;const unsigned maximum = 10000;unsigned loop(unsigned n){ unsigned i = 1; wh... 阅读全文
posted @ 2016-01-22 15:28 健康平安快乐 阅读(141) 评论(0) 推荐(0) 编辑
摘要:2992.357000 1000 A+B Problem1214.840000 1002 487-32791070.603000 1004 Financial Management880.192000 1003 Hangover792.762000 1001 Exponentiati... 阅读全文
posted @ 2016-01-21 14:02 健康平安快乐 阅读(376) 评论(0) 推荐(0) 编辑
摘要:Total Difference Strings 给一个string列表,判断有多少个不同的string,返回个数相同的定义:字符串长度相等并从左到右,或从右往左是同样的字符 abc 和 cba 为视为相同。 采用“哈希表”来存储字符串,在O(N)的时间复杂度内完成。#include #in... 阅读全文
posted @ 2015-12-22 19:19 健康平安快乐 阅读(228) 评论(0) 推荐(0) 编辑
摘要:一,举例应用 在ACM比赛中常使用 stdlib.h 中自带的 qsort 函数,是教科书式的函数指针应用示范。#include #include int comp(const void*a, const void*b){ return *(int*)a - *(int*)b;}int ma... 阅读全文
posted @ 2015-10-09 13:20 健康平安快乐 阅读(341) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示