当前位置:网站首页>Leetcode skimming ---202
Leetcode skimming ---202
2022-07-03 10:35:00 【Long time no see 0327】
subject : Write a function , Its function is to invert the input string . Input string as character array s Given in the form of . Do not allocate extra space to another array , You have to modify the input array in place 、 Use O(1) To solve this problem .
Input :s = ["h","e","l","l","o"]
Output :["o","l","l","e","h"]
Method 2 : Double pointer
class Solution {
public:
void reverseString(vector<char>& s) {
int n = s.size();
for (int left = 0, right = n -1; left < right; left++, right--) {
swap(s[left], s[right]);
}
}
};Complexity analysis
Time complexity :O(N)
Spatial complexity :O(1)
边栏推荐
- Handwritten digit recognition: CNN alexnet
- Weight decay (pytorch)
- What useful materials have I learned from when installing QT
- Ut2014 supplementary learning notes
- 20220601 Mathematics: zero after factorial
- An open source OA office automation system
- Hands on deep learning pytorch version exercise solution -- implementation of 3-2 linear regression from scratch
- 20220607 others: sum of two integers
- Leetcode刷题---374
- Jetson TX2 刷机
猜你喜欢

Multilayer perceptron (pytorch)

2018 Lenovo y7000 black apple external display scheme
![[LZY learning notes -dive into deep learning] math preparation 2.1-2.4](/img/92/955df4a810adff69a1c07208cb624e.jpg)
[LZY learning notes -dive into deep learning] math preparation 2.1-2.4

Powshell's set location: unable to find a solution to the problem of accepting actual parameters

Realize an online examination system from zero

Ut2014 learning notes

Linear regression of introduction to deep learning (pytorch)

ECMAScript--》 ES6语法规范 ## Day1

Configure opencv in QT Creator

Adaptive Propagation Graph Convolutional Network
随机推荐
What did I read in order to understand the to do list
What useful materials have I learned from when installing QT
Leetcode-404: sum of left leaves
20220605 Mathematics: divide two numbers
ECMAScript -- "ES6 syntax specification # Day1
20220603 Mathematics: pow (x, n)
[LZY learning notes dive into deep learning] 3.1-3.3 principle and implementation of linear regression
2-program logic
Automatic derivation of introduction to deep learning (pytoch)
20220604 Mathematics: square root of X
Jetson TX2 刷机
Leetcode - 705 design hash set (Design)
Ind kwf first week
GAOFAN Weibo app
Leetcode-513: find the lower left corner value of the tree
ThreadLocal原理及使用场景
Pytorch ADDA code learning notes
Leetcode刷题---1385
Knowledge map reasoning -- hybrid neural network and distributed representation reasoning
深度学习入门之线性回归(PyTorch)