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

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

  • 相关阅读:
    Linux 安装Samba服务器
    常见状态码StatusCode
    urllib详细版
    set uniion()
    python urljoin
    'gbk' codec can't decode byte 0xad in position 12: illegal multibyte sequence
    php 的windows集成开发环境
    图文并茂解释数字证书(转)
    Web安全测试指南--权限管理
    互联互通协议安全设计
  • 原文地址:https://www.cnblogs.com/simayuhe/p/6148099.html
Copyright © 2011-2022 走看看