随笔分类 - Leetcode
Let coding become one of my hobby and part of my daily life.
摘要:Problem: Reverse a singly linked list. recursion:
阅读全文
摘要:Problem: Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: E
阅读全文
摘要:Problem: Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice i
阅读全文
摘要:Problem: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume
阅读全文
摘要:Problem: Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For ex
阅读全文
摘要:Problem: 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 = "
阅读全文
摘要:Problem: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally id
阅读全文
摘要:Problem: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 ->
阅读全文
摘要:Problem: 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. For exa
阅读全文
摘要:Problem: Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each
阅读全文
摘要:Problem: Invert a binary tree. to One Possible Solution:
阅读全文
摘要:Problem: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the f
阅读全文
摘要:Problem: 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
阅读全文
摘要:Problem: You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1
阅读全文
摘要:Problem: Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "olleh". One possible Solut
阅读全文

浙公网安备 33010602011771号