随笔分类 - LeetCode
Keep learning everyday !
摘要:题目: The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, ca
阅读全文
摘要:题目: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a sin
阅读全文
摘要:题目: Merge 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. 没事来做
阅读全文
摘要:1.题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close i
阅读全文
摘要:题目: Given a linked list, remove the nth node from the end of list and return its head. For example, Note: Given n will always be valid. Try to do this
阅读全文
摘要:题目: Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the tel
阅读全文
摘要:题目: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integ
阅读全文
摘要:题目: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum
阅读全文
摘要:题目: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Example 2: Example 3: 这个函数在collection模块的Counter类中: 于是
阅读全文
摘要:题目: Write a function to find the longest common prefix string amongst an array of strings. Subscribe to see which companies asked this question Subscr
阅读全文
摘要:题目: The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return
阅读全文
摘要:题目: 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 f
阅读全文
摘要:题目: Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in
阅读全文
摘要:题目: 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 hav
阅读全文
摘要:题目: Given an array of integers, every element appears three times except for one. Find that single one. Your algorithm should have a linear runtime co
阅读全文
摘要:题目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 题目只有一句话:把一个按升序排列的数组,装换成一个平衡二叉树。 代码: 很久没研究数据结构了,先
阅读全文
摘要:题目: The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following seq
阅读全文
摘要:题目: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up: Ca
阅读全文
摘要:题目: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3
阅读全文
摘要:题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return 代码: 仔细一看,规律就是本层第一个和最后一个的元素都是1,其他的元素分别等于上一层同
阅读全文