
The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
P A H N
A P L S I I G
Y I R
And then read line by line: “PAHNAPLSIIGYIR”
Write the code that will take a string and make this conversion given a number of rows:
string convert(string text, int nRows);
convert(“PAYPALISHIRING”, 3) should return “PAHNAPLSIIGYIR”.
题目描述:
给出一个整数数组和一个整数target,找出数组中两数之和等于target的数的索引
Solution:
维护两个指针指向当前相加的数组元素位置索引,依次向后移动,直到和等于target,把结果索引保存在一个长度为2的数组中,返回
java:
1 |
|




近期评论