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

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

  • 相关阅读:
    使用InstelliJ IDEA创建Web应用程序
    别了WindowsXP
    在MyEclipse中搭建Spring MVC开发环境
    iPhone中国移动收不到彩信,联通不用设置都可以,具体设置方法:
    WebLogic 服务器配置
    c# 第五课 string
    c# 第五课 regex
    c# 第四课 Arrays
    c# 第四课 interfaces
    c# 第五课 async await
  • 原文地址:https://www.cnblogs.com/simayuhe/p/6148099.html
Copyright © 2011-2022 走看看