算法
SkySuperWL
欢迎吐槽
展开
-
leetcode Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], ret原创 2016-08-15 16:21:24 · 332 阅读 · 0 评论 -
求两个数组交集
下午刚到实验室,看到一个同学在群里发了,他面试阿里的一道算法,求两个数组的交集。两个数组元素是无序的,可重复的。刚才准备吃饭,想起今天还没看算法题,就水了一下。#include <iostream> #include <string> using namespace std;int _tmain(int argc, _TCHAR* argv[]) { char str1[] = "11112原创 2016-08-13 17:10:25 · 596 阅读 · 0 评论 -
leetcode Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.You原创 2016-08-10 21:22:15 · 290 阅读 · 0 评论 -
LeetCode Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example, Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You may no原创 2016-08-09 16:20:30 · 337 阅读 · 0 评论 -
leetcode Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ “((()))”, “(()())”, “(())()”, “()(())”,原创 2016-08-09 11:06:46 · 342 阅读 · 0 评论 -
leetcode Valid Number
Validate if a given string is numeric.Some examples: “0” => true ” 0.1 ” => true “abc” => false “1 a” => false “2e10” => true刷了快一个小时,没有什么算法技巧,就是判断,要判断的临界条件太多了。代码表示的很清楚,直接看代码吧。bool isNumber(char* s原创 2016-08-19 16:03:27 · 350 阅读 · 0 评论 -
leetcode 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”, which the length is 3.Given “bbbbb”, the answer is “b”, with the le原创 2016-08-07 20:48:22 · 340 阅读 · 5 评论 -
leetcode 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 linke原创 2016-08-07 20:40:34 · 407 阅读 · 7 评论 -
leetcode twosum
虽说已经刷了很多题了,但是不能坚持每天都刷,时间一长,之前刷的都忘了,最近复习还是总结一下吧,先上一道很水的题。 1. Two Sum Difficulty: Easy Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may原创 2016-08-07 20:38:50 · 386 阅读 · 5 评论 -
英才网编程
一个整数(int 32)中的数字进行颠倒,当调到后的整数溢出时,返回0。例如-98,返回-89。class solution{ public: int Reverse(int x){ if (x == 0) { return 0; } if (x == INT_MIN) {原创 2016-08-16 20:52:28 · 563 阅读 · 0 评论 -
Leetcode Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible orde原创 2016-08-15 10:51:53 · 356 阅读 · 0 评论