随笔分类 - Leetcode
摘要:/* Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100 */ class Solution { public: string add
阅读全文
摘要:筛法计算素数: class Solution { public: int countPrimes(int n) { vector<bool> isprime(n, true); isprime[0] = false; isprime[1] = false; for (int i = 2; i < s
阅读全文
摘要:Sort a linked list in O(n log n) time using constant space complexity. 链表的归并排序。 /** * Definition for singly-linked list. * struct ListNode { * int val
阅读全文
摘要:Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: A: a1 → a2
阅读全文
摘要:题目描述: /*Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two e
阅读全文
摘要:class Solution { public: int myAtoi(string str) { if (str == "") return 0; //判断是否为空 int i = 0, sign = 1; long long sum = 0; //用long long来存结果,易于判断是否溢出,
阅读全文