随笔分类 -  Algorithms

摘要:代码: 1 class Solution { 2 public: 3 int atoi(string str) { 4 int num = 0; 5 int sign = 1; 6 const int n = str.size(); 7 ... 阅读全文
posted @ 2015-03-04 15:50 Azurewing 阅读(119) 评论(0) 推荐(0)
摘要:代码: 1 class Solution { 2 public: 3 void nextPermutation(vector &num) { 4 5 const auto first = num.begin(); 6 const auto last = nu... 阅读全文
posted @ 2015-03-04 15:25 Azurewing 阅读(138) 评论(0) 推荐(0)
摘要:代码:暴力算法 1 class Solution { 2 public: 3 int strStr(char *haystack, char *needle) { 4 if (!*needle) 5 return 0; 6 int al... 阅读全文
posted @ 2015-03-03 19:46 Azurewing 阅读(160) 评论(0) 推荐(0)
摘要:代码: 1 1 class Solution { 2 2 public: 3 3 int removeElement(int A[], int n, int elem) { 4 4 int index = 0; 5 5 for (int i = 0;... 阅读全文
posted @ 2015-03-03 10:25 Azurewing 阅读(168) 评论(0) 推荐(0)
摘要:代码:class Solution {public: bool isValid(string s) { string left = "([{"; string right = ")]}"; stack stk; for(auto c : ... 阅读全文
posted @ 2015-03-03 00:11 Azurewing 阅读(105) 评论(0) 推荐(0)
摘要:代码: 1 class Solution { 2 public: 3 bool isPalindrome(string s) { 4 transform(s.begin(), s.end(), s.begin(), ::tolower); 5 auto lef... 阅读全文
posted @ 2015-03-02 22:58 Azurewing 阅读(145) 评论(0) 推荐(0)
摘要:算法渣,现实基本都参考或者完全拷贝[戴方勤(soulmachine@gmail.com)]大神的leetcode题解,此处仅作刷题记录。 1 class Solution { 2 public: 3 vector > fourSum(vector &num, int target) ... 阅读全文
posted @ 2015-03-02 14:16 Azurewing 阅读(174) 评论(0) 推荐(0)
摘要:算法渣,现实基本都参考或者完全拷贝[戴方勤(soulmachine@gmail.com)]大神的leetcode题解,此处仅作刷题记录。 1 class Solution { 2 public: 3 int threeSumClosest(vector &num, int target) {... 阅读全文
posted @ 2015-03-01 21:16 Azurewing 阅读(134) 评论(0) 推荐(0)
摘要:算法渣,现实基本都参考或者完全拷贝[戴方勤(soulmachine@gmail.com)]大神的leetcode题解,此处仅作刷题记录。早先AC,现今TLEclass Solution {public: vector > threeSum(vector &num) { vecto... 阅读全文
posted @ 2015-03-01 20:44 Azurewing 阅读(132) 评论(0) 推荐(0)
摘要:算法渣,现实基本都参考或者完全拷贝[戴方勤(soulmachine@gmail.com)]大神的leetcode题解,此处仅作刷题记录。 1 class Solution { 2 public: 3 vector twoSum(vector &numbers, int target) { 4... 阅读全文
posted @ 2015-03-01 18:59 Azurewing 阅读(171) 评论(0) 推荐(0)
摘要:欢迎交流 1.1.26public class TestApp { public static void main(String[] args) { int a = StdIn.readInt(); int b = StdIn.readInt(); ... 阅读全文
posted @ 2014-10-22 19:26 Azurewing 阅读(219) 评论(0) 推荐(0)
摘要:欢迎交流 1.1.1 a. 7 b. 200.0000002 c. true 1.1.2 a. 1.618 b. 10.0 c. true d. 33 1.1.3 1 public class MainApp { 2 public static void main(S... 阅读全文
posted @ 2014-09-22 19:25 Azurewing 阅读(455) 评论(0) 推荐(0)