chenyufeng's starred repositories
26.-Remove-Duplicates-from-Sorted-Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory.
88.-Merge-Sorted-Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. The number of elements initialized in nums1 and nums2 are m and n respectively.
BinaryTree_CPP
用C++实现二叉树的基本操作。
1.-Two-Sum
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.
14.-Longest-Common-Prefix
Write a function to find the longest common prefix string amongst an array of strings.
27.-Remove-Element
Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. The order of elements can be changed. It doesn't matter what you leave beyond the new length.
28.-Implement-strStr-
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
3.-Longest-Substring-Without-Repeating-Characters
Given a string, find the length of the longest substring without repeating characters.
35.-Search-Insert-Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
48.-Rotate-Image
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise).
5.-Longest-Palindromic-Substring
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.
50.-Pow-x-n-
Implement pow(x, n).
58.-Length-of-Last-Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0.
66.-Plus-One
Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list.
67.-Add-Binary
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100".
7.-Reverse-Integer
Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321
70.-Climbing-Stairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
8.-String-to-Integer-atoi-
Implement atoi to convert a string to an integer.
9.-Palindrome-Number
Determine whether an integer is a palindrome. Do this without extra space.
BinarySearchTree_CPP
C++实现二叉查找树的基本操作。
BinaryTreeHeight
求二叉树的高度。
BinaryTreeLeafCount
求二叉树的叶子节点的个数。
BinaryTreePath
求二叉树某条路径节点和为x的路径。
LevelOrderBinaryTree
二叉树进行层序遍历。
MaxLengthSubString
求一个字符串中包含某两个字符的最短子串,输出长度。如string=cadacacbedffffreaaawc,两个字符分别为f,c, 则打印出5,因为最短子串为cbedf。
PowerFunction
两种方式求次方函数。
ReverseLeftRightChild
交换二叉树的左右子树。
TransferStringAndInt
C++中字符串和数字相互转换。
TraverseBinaryTreeNoRecursion
使用非递归方式遍历二叉树。