Leetcode 题目整理
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 题目整理的更多相关文章
- Leetcode 题目整理 climbing stairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- Leetcode 题目整理-3 Palindrome Number & Roman to Integer
9. Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. clic ...
- Leetcode 题目整理-1
1. Two Sum Given an array of integers, return indices of the two numbers such that they add up to a ...
- 【leetcode题目整理】数组中找子集
368. Largest Divisible Subset 题意:找到所有元素都不同的数组中满足以下规则的最大子集,规则为:子集中的任意两个元素a和b,满足a%b=0或者b%a=0. 解答:利用动态规 ...
- Leetcode 题目整理 Sqrt && Search Insert Position
Sqrt(x) Implement int sqrt(int x). Compute and return the square root of x. 注:这里的输入输出都是整数说明不会出现 sqrt ...
- Leetcode 题目整理-8 Count and Say
38. Count and Say The count-and-say sequence is the sequence of integers beginning as follows: 1, 11 ...
- 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 ...
- 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 ...
- Leetcode 题目整理-5 Valid Parentheses & Merge Two Sorted Lists
20. Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', ...
- 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 ...
随机推荐
- jsqlparser和calcite和druid功能对比
需求分析:(用其它方法替代metabase中的某些功能)功能1.通过对sql查询语句的分析,得到所有表名,以及所有表的字段名,字段类型,字段注解信息.功能2.在sql语句执行查询前,校验sql语句是否 ...
- 【重学Node.js 第4篇】实现一个简易爬虫&启动定时任务
实现一个简易爬虫&启动定时任务 课程介绍看这里:https://www.cnblogs.com/zhangran/p/11963616.html 项目github地址:https://gith ...
- 【题解】NOIP2017 提高组 简要题解
[题解]NOIP2017 提高组 简要题解 小凯的疑惑(数论) 不讲 时间复杂度 大力模拟 奶酪 并查集模板题 宝藏 最优解一定存在一种构造方法是按照深度一步步生成所有的联通性. 枚举一个根,随后设\ ...
- $bzoj2560$ 串珠子 容斥+$dp$
正解:容斥+$dp$ 解题报告: 传送门$QwQ$ $umm$虽然题目蛮简练的了但还是有点难理解,,,我再抽象一点儿,就说有$n$个点,点$i$和点$j$之间有$a_{i,j}$条无向边可以连,问有多 ...
- 洛谷$P3620\ [APIO/CTSC 2007]$数据备份 贪心
正解:贪心 解题报告: 传送门$QwQ$ $umm$感觉这种问题还蛮经典的,,,就选了某个就不能选另一个这样儿,就可以用堆模拟反悔操作 举个$eg$,如果提出了$a_i$,那就$a_{i-1}$和$a ...
- 机器学习-Pandas 知识点汇总(吐血整理)
Pandas是一款适用很广的数据处理的组件,如果将来从事机械学习或者数据分析方面的工作,咱们估计70%的时间都是在跟这个框架打交道.那大家可能就有疑问了,心想这个破玩意儿值得花70%的时间吗?咱不是还 ...
- css常用单词
<!-- type = circle表示空心圆 --> <!-- type = disc 表示实心圆 --> <!-- type = square表示方块 ...
- POJ 1269 Intersecting Lines(判断两直线位置关系)
题目传送门:POJ 1269 Intersecting Lines Description We all know that a pair of distinct points on a plane ...
- [小技巧] Windows 命令行显示英文
在 Windows 里 " 运行" 使用 cmd 进行命令行, 如果是Windows 中文版的话,里面的命令输出是中文. 如果要显示英文的话,可以使用如下的命令: chcp 437 ...
- 【转】经典的SQL语句面试题
Student(S#,Sname,Sage,Ssex) 学生表Course(C#,Cname,T#) 课程表SC(S#,C#,score) 成绩表Teacher(T#,Tname) 教师表 问题: 1 ...