1. Two Sum

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution.

Example:

Given nums = [2, 7, 11, 15], target = 9,

Because nums[0] + nums[1] = 2 + 7 = 9,

return [0, 1].

UPDATE (2016/2/13):
The return format had been changed to zero-based indices. Please read the above updated description carefully.

注:给出一个整数向量,和一个目标值,找出向量中加和等于目标值的那两个数所在的位置。(假如只有一组解) (位置索引是从0开始)

6. ZigZag Conversion

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".

注:把一串字母按照"z"形排列,现在要按行读出来。(不懂)

查了一下是这个样子:text="PAYPALISHIRING" , nRows=4 时

P     I    N

A   L S  I G

Y A   H R

P     I

结果是 "PINALSIGYAHRPI".

要弄清楚规律,按列存储一个字符串,然后按行读出来

Leetcode 题目整理的更多相关文章

  1. Leetcode 题目整理 climbing stairs

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

  2. Leetcode 题目整理-3 Palindrome Number & Roman to Integer

    9. Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. clic ...

  3. Leetcode 题目整理-1

    1. Two Sum Given an array of integers, return indices of the two numbers such that they add up to a ...

  4. 【leetcode题目整理】数组中找子集

    368. Largest Divisible Subset 题意:找到所有元素都不同的数组中满足以下规则的最大子集,规则为:子集中的任意两个元素a和b,满足a%b=0或者b%a=0. 解答:利用动态规 ...

  5. Leetcode 题目整理 Sqrt && Search Insert Position

    Sqrt(x) Implement int sqrt(int x). Compute and return the square root of x. 注:这里的输入输出都是整数说明不会出现 sqrt ...

  6. Leetcode 题目整理-8 Count and Say

    38. Count and Say The count-and-say sequence is the sequence of integers beginning as follows: 1, 11 ...

  7. Leetcode 题目整理-7 Remove Element & Implement strStr()

    27. Remove Element Given an array and a value, remove all instances of that value in place and retur ...

  8. Leetcode 题目整理-6 Swap Nodes in Pairs & Remove Duplicates from Sorted Array

    24. Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head. For ...

  9. Leetcode 题目整理-5 Valid Parentheses & Merge Two Sorted Lists

    20. Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', ...

  10. Leetcode 题目整理-4 Longest Common Prefix & Remove Nth Node From End of List

    14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array ...

随机推荐

  1. [梁山好汉说IT] 以水浒传为例讲解贝叶斯定理

    0x00 摘要 看看呼延灼如何利用贝叶斯定理来判断 "自己是否是公明哥哥的心腹". 0x01 IT概念 1. 贝叶斯定理 贝叶斯定理是用来解决"逆概率"问题的, ...

  2. MyBatis 注解开发+逆向(Generator)

    注解开发 最初设计时,MyBatis 是一个 XML 驱动的框架.配置信息是基于 XML 的,而且映射语句也是定义在 XML 中的.随着技术的更新发展,对于开发效率要求也原来越高,特别是一些小型项目; ...

  3. 从头学pytorch(十二):模型保存和加载

    模型读取和存储 总结下来,就是几个函数 torch.load()/torch.save() 通过python的pickle完成序列化与反序列化.完成内存<-->磁盘转换. Module.s ...

  4. 使用Django进行后端开发

    目录 更换pip源 搭建虚拟环境 项目目录设置 项目相关配置 更换pip源 更换pip源 搭建虚拟环境 搭建虚拟开发环境 项目目录设置 项目目录设置 项目相关配置 项目相关配置

  5. Spring MVC拦截器配置

    Spring MVC拦截器配置 (1)自定义拦截器 package learnspringboot.xiao.other; import org.springframework.web.servlet ...

  6. delphi7 如何描述窗体上的全部控件

    在delphi开发中,经常需要用到窗体中控件的name名来进行对象方法或属性的调用,所以如何对delphi窗体进行简洁,清楚,完整的描述就很重要.最好能不看界面也能进行界面编码,具体如下表所示: xx ...

  7. 洛谷P4141 消失之物 题解 背包问题扩展

    题目链接:https://www.luogu.com.cn/problem/P4141 题目大意: 有 \(n\) 件物品,求第 \(i\) 件物品不能选的时候(\(i\) 从 \(1\) 到 \(n ...

  8. 「Vijos 1284」「OIBH杯NOIP2006第二次模拟赛」佳佳的魔法阵

    佳佳的魔法阵 背景 也许是为了捕捉猎物(捕捉MM?),也许是因为其它原因,总之,佳佳准备设计一个魔法阵.而设计魔法阵涉及到的最关键问题,似乎就是那些带有魔力的宝石的摆放-- 描述 魔法阵是一个\(n ...

  9. 「Luogu P3183」[HAOI2016]食物链 解题报告

    身为一个蒟蒻,由于刷不过[NOI2001]食物链 于是出门左转写了道另一道假的食物链 戳这里 这里的食物链个条数其实就是有向图的路径数(应该是这么说吧,我弱) 思路: 拓扑(Topulogy)(一本正 ...

  10. Java网络编程——TCP图片上传

    1.编写一个服务器端程序,用来接收图片.创建一个监听指定端口号的ServerSocket服务端对象,在while(true)无限循环中持续调用ServerSocket的accept()方法来接收客户端 ...