
算法
文章平均质量分 77
K_W
这个作者很懒,什么都没留下…
展开
-
LeetCode 1 : Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe原创 2015-07-13 15:51:25 · 289 阅读 · 0 评论 -
LeetCode (算法,难度,频率)
IdQuestionDifficultyFrequencyData StructuresAlgorithms1Two Sum25array + setsort + two pointers2Add Two Numbers34linked listtwo point转载 2015-07-13 15:55:40 · 1081 阅读 · 0 评论 -
uva227 - Puzzle
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=163code#include#includechar puzzle[5][5];bool move(char chs[5][5], int x,int y, in原创 2015-09-04 14:49:57 · 408 阅读 · 0 评论 -
uva232 - Crossword Answers
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=168code#include#includechar puzzle[20][20];int flags[20][20];bool isEligible(int i, in原创 2015-09-04 17:58:21 · 370 阅读 · 0 评论 -
uva272 - TEX Quotes
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=4&problem=208&mosmsg=Submission+received+with+ID+15887888code#includeint main(){原创 2015-08-30 17:43:40 · 379 阅读 · 0 评论 -
uva10082 - WERTYU
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=12&problem=1023&mosmsg=Submission+received+with+ID+15888154 code #includechar原创 2015-08-30 17:44:28 · 527 阅读 · 0 评论 -
uva340 - Master-Mind Hints
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=276code#include#define maxn 1010int main(){int n ,a[maxn],b[maxn];int gameC原创 2015-08-30 17:48:44 · 403 阅读 · 0 评论 -
uva1584 - Circular Sequence
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4459code#include#includeconst int maxn = 105;int less(char* s, int ans, int k)原创 2015-09-01 16:36:08 · 377 阅读 · 0 评论 -
uva1225 - Digit Counting
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3666code{优快云:CODE:#include#includeint main(){int total[10];int n;s原创 2015-09-02 17:08:07 · 319 阅读 · 0 评论 -
uva1368 - DNA Consensus String
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4114code#includechar DNAs[55][1005];char result[1005];int main(){ int caseN; sc原创 2015-09-04 20:18:23 · 261 阅读 · 0 评论 -
uva11292 - Dragon of Loowater
链接 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=24&problem=2267&mosmsg=Submission+received+with+ID+15876651 code #include#includeusing n原创 2015-08-30 17:42:23 · 389 阅读 · 0 评论 -
uva1583 - Digit Generator
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4458code#includeint main(){int n;scanf("%d",&n);while(n--)原创 2015-08-31 21:56:13 · 362 阅读 · 0 评论 -
uva1588 - Kickdown
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4463code#include#include#includeusing namespace std;int getMinLen(char* n1 ,char原创 2015-09-05 14:37:54 · 410 阅读 · 0 评论 -
uva455 - Periodic Strings
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=396code#include#includeint main(){int n;scanf("%d",&n);while(n--){原创 2015-09-04 09:53:45 · 302 阅读 · 0 评论 -
uva1587 - Box
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4462code#include#include#includeusing namespace std;struct Node{ int w,h; bool oper原创 2015-09-04 23:15:27 · 481 阅读 · 0 评论 -
uva401 - Palindromes
链接地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=342code#include#include#includeconst char* rev = "A 3 HIL JM O 2TUVWXY51SE z 8 ";原创 2015-08-30 17:46:20 · 339 阅读 · 0 评论 -
uva1586 - Molar mass
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4461code#include#include#includeconst int maxLen = 100;int getIndex(char *原创 2015-09-02 16:03:58 · 385 阅读 · 0 评论 -
uva10340 - All in All
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1281code#include#includechar s[100005],t[100005];int main(){ while(scanf("%s %s",原创 2015-09-04 21:24:49 · 314 阅读 · 0 评论 -
uva1585 - Score
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4460code#include#includeconst int maxLen = 100;int main(){char s[maxLen];原创 2015-09-01 23:06:34 · 454 阅读 · 0 评论 -
uva489 - Hangman Judge
链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=430code#include#includeint letters[30];char words[100005],guess[100005];int main原创 2015-09-10 16:43:37 · 362 阅读 · 0 评论 -
leetcode-1. Two Sum
前言:刷了几天简单的题找感觉,现在决定按照序号来做题。Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solu原创 2016-08-18 20:35:36 · 205 阅读 · 0 评论 -
leetcode-2. Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link原创 2016-08-18 21:19:26 · 490 阅读 · 0 评论 -
leetcode-344. Reverse String
重新刷题,由于计划是先刷一遍,从自己最熟悉的java开始刷题,刷完之后考虑尝试用其他语言刷题。——————————————————————————————————————————————————————————Write a function that takes a string as input and returns the string reversed.Examp原创 2016-08-10 21:10:32 · 241 阅读 · 0 评论 -
leetcode-292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the原创 2016-08-10 21:32:54 · 243 阅读 · 0 评论 -
leetcode-371. Sum of Two Integers
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3.public class Solution { public int getSum(int a, in原创 2016-08-10 22:35:47 · 246 阅读 · 0 评论 -
leetcode-383. Ransom Note
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constru原创 2016-08-11 15:21:36 · 709 阅读 · 0 评论 -
leetcode-258. Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has on原创 2016-08-11 17:06:22 · 220 阅读 · 0 评论 -
leetcode-104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node./** * Definition for a binary tre原创 2016-08-11 20:42:03 · 285 阅读 · 0 评论 -
leetcode-349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.T原创 2016-08-11 21:05:06 · 291 阅读 · 0 评论 -
leetcode-171. Excel Sheet Column Number
Given a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 public cla原创 2016-08-11 21:36:11 · 331 阅读 · 0 评论 -
leetcode-217. Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element原创 2016-08-11 23:39:53 · 207 阅读 · 0 评论 -
leetcode-350. Intersection of Two Arrays II
Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note:Each element in the result should appear as ma原创 2016-08-12 01:14:09 · 218 阅读 · 0 评论 -
Leetcode-73. Set Matrix Zeroes
前言:为了后续的实习面试,开始疯狂刷题,非常欢迎志同道合的朋友一起交流。因为时间比较紧张,目前的规划是先过一遍,写出能想到的最优算法,第二遍再考虑最优或者较优的方法。如有错误欢迎指正。博主首发优快云,mcf171专栏。博客链接:mcf171的博客——————————————————————————————Given a m x n matrix, if an el原创 2016-10-08 22:47:57 · 296 阅读 · 0 评论 -
leetcode-3. Longest Substring Without Repeating Characters
前言:最近开学事情特别多,隔了一个月没刷题,真是蛋疼。----------------------Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc",原创 2016-09-13 15:06:26 · 210 阅读 · 0 评论 -
Leetcode-415. Add Strings
前言:正好碰见Leetcode有一次在线笔试,测试一下,还是挺开心的,全做出来了Rank:98/869。如有错误欢迎指正。博主首发优快云,mcf171专栏。博客链接:mcf171的博客——————————————————————————————Given two non-negative numbers num1 and num2 represented原创 2016-10-09 20:14:55 · 288 阅读 · 0 评论 -
Leetcode-416. Partition Equal Subset Sum
前言:正好碰见Leetcode有一次在线笔试,测试一下,还是挺开心的,全做出来了Rank:98/869。如有错误欢迎指正。博主首发优快云,mcf171专栏。博客链接:mcf171的博客——————————————————————————————Given a non-empty array containing only positive integers, fi原创 2016-10-09 20:16:54 · 1286 阅读 · 0 评论 -
Leetcode-418. Sentence Screen Fitting
前言:正好碰见Leetcode有一次在线笔试,测试一下,还是挺开心的,全做出来了Rank:98/869。如有错误欢迎指正。博主首发优快云,mcf171专栏。博客链接:mcf171的博客——————————————————————————————Given a rows x cols screen and a sentence represented by a li原创 2016-10-09 20:21:45 · 2223 阅读 · 1 评论 -
Leetcode-74. Search a 2D Matrix
前言:为了后续的实习面试,开始疯狂刷题,非常欢迎志同道合的朋友一起交流。因为时间比较紧张,目前的规划是先过一遍,写出能想到的最优算法,第二遍再考虑最优或者较优的方法。如有错误欢迎指正。博主首发优快云,mcf171专栏。博客链接:mcf171的博客——————————————————————————————Write an efficient algorithm t原创 2016-10-10 15:06:36 · 313 阅读 · 0 评论 -
Leetcode-75. Sort Colors
前言:为了后续的实习面试,开始疯狂刷题,非常欢迎志同道合的朋友一起交流。因为时间比较紧张,目前的规划是先过一遍,写出能想到的最优算法,第二遍再考虑最优或者较优的方法。如有错误欢迎指正。博主首发优快云,mcf171专栏。博客链接:mcf171的博客——————————————————————————————Given an array with n objects原创 2016-10-10 18:11:42 · 261 阅读 · 0 评论 -
Leetcode-77. Combinations
前言:为了后续的实习面试,开始疯狂刷题,非常欢迎志同道合的朋友一起交流。因为时间比较紧张,目前的规划是先过一遍,写出能想到的最优算法,第二遍再考虑最优或者较优的方法。如有错误欢迎指正。博主首发优快云,mcf171专栏。博客链接:mcf171的博客——————————————————————————————Given two integers n and k, re原创 2016-10-11 14:51:48 · 245 阅读 · 0 评论