Problem Statement: 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… Continue reading Container with Most Water and Longest Common Prefix

# Tag: Algorithm

## Regular_Expression _Matching

Let me continue.... Problem Statement: Given an input string (s) and a pattern (p), 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). Note: s could be empty and contains only… Continue reading Regular_Expression _Matching

## ZigZag && ATOI

OK, Let's continue.... ZIGZAG Problem Statement: 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… Continue reading ZigZag && ATOI

## Longest_Palindromic_ Sub_String

OK, Let's continue.... Problem Statement: Given a string s, find the longest palindromic sub string in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: "cbbd" Output: "bb" Solution One: Brute Force Simple but not efficient.… Continue reading Longest_Palindromic_ Sub_String

## Median_of_Two_ Sorted_Arrays

Median of Two Sorted Arrays Problem Statement: 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)). You may assume nums1 and nums2 cannot be both empty. Example 1: nums1 = [1, 3] nums2 =… Continue reading Median_of_Two_ Sorted_Arrays

## Longest_Sub_String_ No_Repeat_Characters

Let me continue my work here. Longest substring without Repeating Characters Problem Statement: Given a string, find the length of the longest sub string without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", which the length is 3. Example 2: Input: "bbbbb" Output: 1 Explanation: The answer is "b", with the length… Continue reading Longest_Sub_String_ No_Repeat_Characters

## Two_Sum and Add_Two_Numbers

I am trying to solve some algorithm problems in Leetcode recently. I plan to write down all the solutions either written by myself or found in the internet... I want to keep track of all these solutions and plan to write an article like this weekly, and hopefully, these articles could be helpful to you,… Continue reading Two_Sum and Add_Two_Numbers