19 Dec 2015
Question
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 ...
19 Dec 2015
Question
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.
Solution
#include <string>
#include <utility>
using namespace std;
class Solution {
publi...
15 Dec 2015
Question
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))\).
Solution
#include <vector>
#include <cmath>
using namespace std;
class Solution {
public...
10 Dec 2015
Question
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.
Solution
#inclu...
03 Dec 2015
Question
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...