摘要:
问题描述: 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: N 阅读全文
摘要:
问题描述: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. Example: Follow up:Could you do it without 阅读全文
摘要:
问题描述: Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example: 思路: 二叉树的问题,首先考虑递归算法,用深度优先搜索。 为了体现模块化思想,一般讲 阅读全文
摘要:
问题描述: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wik 阅读全文
摘要:
问题描述: 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 occ 阅读全文
摘要:
问题描述: Count the number of prime numbers less than a non-negative number, n. Example: 思路: 1、最暴力的方法就是循环遍历,用两个for循环嵌套实现,但是整个代码运行时间太长,提交通不过 2、采用'Sieve of 阅读全文
摘要:
问题描述: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopp 阅读全文
摘要:
问题描述: Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Example 2: Note: Try to come up as many solutions 阅读全文
摘要:
问题描述: Given an integer n, return the number of trailing zeroes in n!. Example 1: Example 2: Note: Your solution should be in logarithmic time complexi 阅读全文
摘要:
问题描述: Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer poswhich represents the 阅读全文