摘要: 题目描述: 解法(交叉映射): class Solution {public: bool isIsomorphic(string s, string t) { unordered_map record1; unordered... 阅读全文
posted @ 2019-08-30 22:51 DH_HUSTer 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 解法一(厄拉多塞筛法): class Solution {public: int countPrimes(int n) { vector dp(n,0); int res=0; for(int i... 阅读全文
posted @ 2019-08-30 22:29 DH_HUSTer 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 解法一(自然想法): /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNo... 阅读全文
posted @ 2019-08-30 20:24 DH_HUSTer 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 解法一(自然解法使用两个栈 入队 - O(1), 出队 - O(n)): class MyQueue { stack stk1; stack stk2; int Front;public: /** Initialize y... 阅读全文
posted @ 2019-08-30 19:14 DH_HUSTer 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 解法一(两个队列,压入 -O(1), 弹出 -O(n)) class MyStack { queue que1; queue que2; int Top;public: /** Initialize your data... 阅读全文
posted @ 2019-08-30 16:47 DH_HUSTer 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 解法: //双指针交换class Solution {public: void reverseString(vector& s) { int l=0,r=s.size()-1; char temp; ... 阅读全文
posted @ 2019-08-30 15:27 DH_HUSTer 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 解法一(转换为字符串): class Solution {public: bool isPalindrome(int x) { string temp=to_string(x); return isPalindr... 阅读全文
posted @ 2019-08-30 15:20 DH_HUSTer 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 解法一: class Solution {public: int myAtoi(string str) { int index=0; bool neg=0; long long res=0; ... 阅读全文
posted @ 2019-08-30 14:16 DH_HUSTer 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 解法: class Solution {public: int reverse(int x) { int res=0; int rem; //余数 while(x!=0){ ... 阅读全文
posted @ 2019-08-30 13:27 DH_HUSTer 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 解法: class Solution {public: string convert(string s, int numRows) { int n = s.size(); if (numRows >= n||... 阅读全文
posted @ 2019-08-30 13:00 DH_HUSTer 阅读(11) 评论(0) 推荐(0) 编辑