原创 *leetcode #134 in cpp
There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with
原创 leetcode #125 in cpp
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For ex
原创 leetcode #119 in cpp
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Co
原创 *leetcode #132 in cpp
Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts ne
原创 leetcode #131 in cpp
Solution: We have already done in #4 about how to find palindrome in a string. Given isPal[i][j] which represents wheth
原创 *leetcode #162 in cpp
A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find
原创 leetcode #144 in cpp
Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3},
原创 *leetcode 138 in cpp
A linked list is given such that each node contains an additional random pointer which could point to any node in the
原创 leetcode #153 in cpp
Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6
原创 leetcode #165 in cpp
Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 return -1,
原创 leetcode #155 in cpp
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push ele
原创 leetcode #150 in cpp
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each ope
原创 *leetcode #136 in cpp
Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm s
原创 leetcode #154 in cpp
Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time
原创 #leetcode #142 in cpp
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify