標籤:: LeetCode

0

Count and Say

Count and SayThe count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, … 1 is read off as “one 1” or 11. 11 is read off as “two 1s” or 21. 21 is read off a

0

Valid Sudoku

Valid SudokuThe Sudoku board could be partially filled, where empty cells are filled with the character ‘.’. Note: A valid Sudoku board (partially filled) is not necessarily solvable. Only the fille

0

Remove Element

Remove ElementGiven 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

0

Remove Duplicates from Sorted Array

Remove Duplicates from Sorted ArrayGiven 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 arra

0

Swap Nodes in Pairs

Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head. For example: 1Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm s

0

Merge Two Sorted Lists

Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 提示 解題應用 LinkedList Pointer

0

Valid Parentheses

Valid ParenthesesGiven a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid. The brackets must close in the correct order, “()” and “()[]{}”

0

Remove Nth Node From End of List

Remove Nth Node From End of ListGiven a linked list, remove the nth node from the end of list and return its head. Example: 123Given linked list: 1->2->3->4->5, and n = 2.After removing t

0

Longest Common Prefix

Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings. 提示 解題應用 String Prefix String Default:123func longestCommonPrefix(strs []string) s

0

Roman to Integer

Roman to IntegerGiven a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 提示 解題應用 Math 規律觀察 String 規律觀察 Default:12func romanToInt(s strin

0

Reverse Integer

Reverse IntegerReverse digits of an integer. Exmaple1:1x = 123, return 321 Exmaple2:1x = -123, return -321 Have you thought about this? Here are some good questions to ask before coding. Bonus points

0

Palindrome Number

Palindrome NumberDetermine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer

0

ZigZag Conversion

ZigZag ConversionThe 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) Exmaple:1

0

Two Sum

Two SumGiven 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. Exmaple:1234Given nums