随笔分类 -  LeetCode

摘要:Write a function to find the longest common prefix string amongst an array of strings. 对给定的String类型的数组,要求写一个方法返回数组中字符串的最长公共前缀。 解法一:将数组中第一个字符串假定为公共前缀,从 阅读全文
posted @ 2022-02-04 23:30 zeroingToOne 阅读(57) 评论(0) 推荐(0)
摘要:Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element i 阅读全文
posted @ 2018-04-03 22:17 zeroingToOne 阅读(190) 评论(0) 推荐(0)
摘要:Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a lette 阅读全文
posted @ 2018-03-20 12:54 zeroingToOne 阅读(201) 评论(0) 推荐(0)
摘要:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c 阅读全文
posted @ 2018-03-15 22:17 zeroingToOne 阅读(199) 评论(0) 推荐(0)
摘要:Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return true.s = "rat", t = 阅读全文
posted @ 2018-03-15 10:02 zeroingToOne 阅读(214) 评论(0) 推荐(0)
摘要:Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front 阅读全文
posted @ 2018-03-14 22:02 zeroingToOne 阅读(159) 评论(0) 推荐(0)
摘要:Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. to 阅读全文
posted @ 2018-03-14 21:42 zeroingToOne 阅读(176) 评论(0) 推荐(0)
摘要:Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrenc 阅读全文
posted @ 2018-03-09 22:25 zeroingToOne 阅读(183) 评论(0) 推荐(0)
摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit 阅读全文
posted @ 2018-03-09 16:06 zeroingToOne 阅读(144) 评论(0) 推荐(0)
摘要:Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime complex 阅读全文
posted @ 2018-03-03 13:19 zeroingToOne 阅读(119) 评论(0) 推荐(0)
摘要:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2018-03-01 21:28 zeroingToOne 阅读(191) 评论(0) 推荐(0)
摘要:Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: 题意:给定以字符串形式表示的两个非负整数num1和num2,返回这两个整数的和。No 阅读全文
posted @ 2018-01-30 22:01 zeroingToOne 阅读(273) 评论(0) 推荐(0)
摘要:Given an m * n matrix M initialized with all 0's and several update operations. Operations are represented by a 2D array, and each operation is repres 阅读全文
posted @ 2018-01-14 14:56 zeroingToOne 阅读(135) 评论(0) 推荐(0)
摘要:You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number 阅读全文
posted @ 2018-01-10 21:38 zeroingToOne 阅读(135) 评论(0) 推荐(0)
摘要:A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128 阅读全文
posted @ 2018-01-10 20:24 zeroingToOne 阅读(236) 评论(0) 推荐(0)
摘要:Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note:n is positive and will fit within the range of a 32-bi 阅读全文
posted @ 2018-01-09 15:46 zeroingToOne 阅读(144) 评论(0) 推荐(0)
摘要:Given an integer, write a function to determine if it is a power of three. Follow up:Could you do it without using any loop / recursion? Credits:Speci 阅读全文
posted @ 2018-01-06 14:49 zeroingToOne 阅读(265) 评论(0) 推荐(0)
摘要:Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For exa 阅读全文
posted @ 2018-01-05 20:30 zeroingToOne 阅读(319) 评论(0) 推荐(0)
摘要:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 阅读全文
posted @ 2018-01-04 21:53 zeroingToOne 阅读(236) 评论(0) 推荐(0)
摘要:Given an integer, write a function to determine if it is a power of two. Credits:Special thanks to @jianchao.li.fighter for adding this problem and cr 阅读全文
posted @ 2018-01-04 20:14 zeroingToOne 阅读(198) 评论(0) 推荐(0)