Skip to content
My solutions for LeetCode problems.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/main/java/leetcodeproblemssolutions
.gitignore
LICENSE
README.md
pom.xml

README.md

My soutions for the LeetCode problems.

Easy Problems

Problem 1 Two Sum

Problem description
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, and you may not use the same element twice.

Problem 7 Reverse Integer

Problem description
Given a 32-bit signed integer, reverse digits of an integer.

Problem 9 Palindrome Number

Problem description
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.

Problem 14 Longest Common Prefix

Problem description
Write a function to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string "".

Medium Problems

Problem 2 Add Two Numbers

Problem description
You are given two non-empty linked lists representing two non-negative integers. 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.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.

Problem 6 Zig Zag Conversion

Problem description
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"

Hard Problems

Problem 65 Valid Number

Problem description
Validate if a given string can be interpreted as a decimal number.

Some examples:
"0" => true
" 0.1 " => true
"abc" => false
"1 a" => false
"2e10" => true
" -90e3   " => true
" 1e" => false
"e3" => false
" 6e-1" => true
" 99e2.5 " => false
"53.5e93" => true
" --6 " => false
"-+3" => false
"95a54e53" => false

Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one.
However, here is a list of characters that can be in a valid decimal number:

* Numbers 0-9
* Exponent - "e"
* Positive/negative sign - "+"/"-"
* Decimal point - "."

Of course, the context of these characters also matters in the input.
You can’t perform that action at this time.