
LeetCode
天上地下,唯我独尊
这个作者很懒,什么都没留下…
展开
-
力扣 7整数反转
给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。 class Solution { public: int reverse(int x) { long long res = 0; while(x){ res = 10*res + x%10; x /= 10; } ...原创 2020-02-17 13:46:13 · 214 阅读 · 0 评论 -
力扣6 Z字形变换
将一个给定字符串根据给定的行数,以从上往下、从左到右进行 Z 字形排列。 比如输入字符串为 “LEETCODEISHIRING” 行数为 3 时,排列如下: L C I R E T O E S I I G E D H N 之后,你的输出需要从左往右逐行读取,产生出一个新的字符串,比如:“LCIRETOESIIGEDHN”。 请你实现这个将字符串进行指定行数变换的函数: st...原创 2020-02-17 13:22:04 · 213 阅读 · 0 评论 -
1-5:Two Sum、Add Two Numbers、Longest Substring Without Repeating Characters
https://leetcode.com/problems/two-sum 1.Two Sum 暴力枚举 class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> res; for(int i =...原创 2019-08-29 11:14:34 · 130 阅读 · 0 评论