Ruizhi Ma's Blog

Keep Calm and Carry On

Problem 198

House Robber

问题描述 You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjace...

Problem 157

Read N Characters Given Read4

问题描述 The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number of characters read. For example, it returns 3 if there is only 3 characters left ...

HashSet

HashSet底层实现

# package cn.sxt.myCollection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; public class SxtHashSet { HashMap map; private static final O...

HashSet

HashSet的基本用法

TestHashMap类 package cn.sxt.collection; import java.util.HashSet; import java.util.Set; /* * 测试HashSet的基本用法 * Set没有顺序,不可重复 * List有顺序,可重复 */ public class TestHashSet { public static void ma...

Problem 191

Number of 1 Bits

问题描述 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: Input: 00000000000000000000000000001011 Output: 3 Exp...

Problem 190

Reverse Bits

问题描述 Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 Output: 00111001011110000010100101000000 Explanation: The input binary string 00000010...

Problem 170

Two Sum III Data Structure Design

问题描述 Design and implement a TwoSum class. It should support the following operations: add and find. add - Add the number to an internal data structure. find - Find if there exists any pair of num...

Problem 172

Factorial Trailing Zeros

问题描述 Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explanation: 3! = 6, no trailing zero. Example 2: Input: 5 Output: 1 Explanation: 5! = 120...

Problem 195

Tenth Line

问题描述 Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has the following content: Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 Li...

Problem 183

Customers Who Never Order

问题描述 https://leetcode.com/problems/customers-who-never-order/ 解决思路 用LEFT JOIN通过ON的条件,将两个表连接,筛选出tb2中Id为空的,即为答案。 问题解惑 ON和WHERE的区别? ON是连接条件;WHERE是筛选条件 代码 # Write your MySQL query statement below SE...