zoukankan      html  css  js  c++  java
  • 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".

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

  • 相关阅读:
    洛谷—— P3353 在你窗外闪耀的星星
    洛谷—— P1238 走迷宫
    洛谷—— P1262 间谍网络
    9.8——模拟赛
    洛谷—— P1189 SEARCH
    算法
    May 22nd 2017 Week 21st Monday
    May 21st 2017 Week 21st Sunday
    May 20th 2017 Week 20th Saturday
    May 19th 2017 Week 20th Friday
  • 原文地址:https://www.cnblogs.com/simayuhe/p/6148099.html
Copyright © 2011-2022 走看看