原创 leetcode筆記:Majority Element
一. 題目描述 Given an array of size n, find the majority element. The majority element is the element that appears more
原创 leetcode筆記:Word Pattern
一. 題目描述 Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, suc
原创 leetcode筆記:Rectangle Area
一. 題目描述 Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its b
原创 leetcode筆記:Contains Duplicate II
一. 題目描述 Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the
原创 leetcode筆記:Majority Element II
一. 題目描述 Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm shou
原创 《劍指offer》約瑟夫環問題
一、題目描述 0, 1, ..., n - 1這n個數字排成一個圓圈,從數字0開始每次從這個圓圈裏刪除第m個數字。求出這個圓圈裏剩下的最後一個數字。 輸入: 每組數據一行,包含2個整數n和m,分別表示0 到 n - 1 的序列和指定刪除的
原创 leetcode筆記:Merge Two Sorted Lists
一. 題目描述 Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the
原创 《劍指offer》不用加減乘除做加法
一、題目描述 寫一個函數,求兩個整數之和,要求在函數體內不得使用+、-、*、/四則運算符號。 輸入: 輸入可能包含多個測試樣例。 對於每個測試案例,輸入爲兩個整數a和b。 輸出: 對應每個測試案例,輸出m+n的值。 樣例輸入:
原创 《劍指offer》把字符串轉換成整數
一、題目描述 將一個字符串轉換成一個整數,要求不能使用字符串轉換整數的庫函數。 輸入: 輸入可能包含多個測試樣例。 對於每個測試案例,輸入爲一個合法或者非法的字符串,代表一個整數n。 輸出: 輸入爲一個合法的字符串,可以轉換成一定
原创 leetcode筆記:Reverse Vowels of a String
一. 題目描述 Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s = "h
原创 leetcode筆記:Reverse String
一. 題目描述 Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", retu
原创 leetcode筆記:Excel Sheet Column Number
一. 題目描述 Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B
原创 leetcode筆記:Reconstruct Itinerary
一. 題目描述 Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct
原创 leetcode筆記:Remove Linked List Elements
一. 題目描述 Remove all elements from a linked list of integers that have value val. Example Given: 1 --> 2 --> 6 --> 3 -->
原创 leetcode筆記:Dungeon Game
一. 題目描述 The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeo