leetcode

Coding on LeetCode Online Judge

leetcode(leetcode website)

a13

question: Roman to Integer
my answer


Given a roman numeral, convert it to an integer.

Input is guaranteed to be within the range from 1 to 3999.

a12

question: Integer to Roman
my answer1|my answer2|my answer3


Given an integer, convert it to a roman numeral.

Input is guaranteed to be within the range from 1 to 3999.

a11

question: Container With Most Water
my answer


Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.

a10

question: Palindrome Number
my answer


Implement regular expression matching with support for '.' and '*'.

'.' Matches any single character.

'*' Matches zero or more of the preceding element.

The matching should cover the entire input string (not partial).

The function prototype should be:

bool isMatch(const char s, const char p)

Some examples:

isMatch("aa","a") → false

isMatch("aa","aa") → true

isMatch("aaa","aa") → false

isMatch("aaaaa", "a") → true

isMatch("aa", ".
") → true

isMatch("ab", ".") → true

isMatch("aab", "c
a*b") → true

a9

question: Palindrome Number
my answer


Determine whether an integer is a palindrome. Do this without extra space.

a8

question: String to Integer (atoi)
my answer


Implement atoi to convert a string to an integer.

Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.

a7

question: Reverse Integer
my answer


Reverse digits of an integer.

Example1: x = 123, return 321

Example2: x = -123, return -321

a6

question: ZigZag Conversion
my answer


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

a5

question: Longest Palindromic Substring
my answer


Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.

a4

question: Median of Two Sorted Arrays
my answer


There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).

a3

question: Longest Substring Without Repeating Characters

my answer and leetcode answer


Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.

a2

question: Add Two Numbers
my answer


You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8

a1

question: Two Sum
my answer


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

About Me

Email: ityoung@126.com

转载于:https://www.cnblogs.com/ityoung/p/5396160.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值