摘要:Write a function that takes an unsigned integer and return the number of '1' bits it has (also known as the Hamming weight). Example 1: Example 2: Exa
阅读全文
摘要:Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements
阅读全文
摘要:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen
阅读全文
摘要:Given a string containing only three types of characters: '(', ')' and ' ', write a function to check whether this string is valid. We define the vali
阅读全文
摘要:Given an array nums of n integers where n 1, return an array output such that output[i] is equal to the product of all the elements of nums except num
阅读全文
摘要:You are given a string s containing lowercase English letters, and a matrix shift, where shift[i] = [direction, amount]: direction can be 0 (for left
阅读全文
摘要:Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. Example 1: Example 2: Note: The length of the giv
阅读全文
摘要:We have a collection of stones, each stone has a positive integer weight. Each turn, we choose the two heaviest stones and smash them together. Suppos
阅读全文
摘要:Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe
阅读全文
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) Push element x onto stack. pop() Removes the
阅读全文
摘要:Given two strings S and T, return if they are equal when both are typed into empty text editors. means a backspace character. Example 1: Example 2: Ex
阅读全文
摘要:Given a non empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middl
阅读全文
摘要:Given an integer array arr, count element x such that x + 1 is also in arr. If there're duplicates in arr, count them seperately. Example 1: Example 2
阅读全文
摘要:Given an array of strings, group anagrams together. Example: Note: All inputs will be in lowercase. The order of your output does not matter. 这道题就是用每个
阅读全文
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple
阅读全文
摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction
阅读全文
摘要:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non zero elements. Example: Input:
阅读全文
摘要:Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Inpu
阅读全文
摘要:Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive intege
阅读全文
摘要:从今天开始努力刷题,用这个帖子来记录刷题的进度。也方便自己的寻找。 题号 题目 复习 1 Two Sum Y 2 Add Two Numbers Y 3 Longest Substring Without Repeating Characters Y 4 Median of Two Sorted A
阅读全文
摘要:Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runti
阅读全文