随笔分类 -  LeetCode

上一页 1 ··· 7 8 9 10 11 12 13 14 下一页
摘要:Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used. Note: All letters in hexadec 阅读全文
posted @ 2017-07-19 18:18 immjc 阅读(150) 评论(0) 推荐(0)
摘要:Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: 给定两个只含有数字字符串,将字符串中的数字和返回一个字符串。并且要求不能使用整数类库 阅读全文
posted @ 2017-07-19 17:06 immjc 阅读(114) 评论(0) 推荐(0)
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 将一个有序的数组转换为一棵高度平衡的二叉树。这道题像中序遍历的逆过程。所以先找到数组中中间位置的值作为树 阅读全文
posted @ 2017-07-19 16:34 immjc 阅读(112) 评论(0) 推荐(0)
摘要: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 longestpath betwee 阅读全文
posted @ 2017-07-19 16:13 immjc 阅读(140) 评论(0) 推荐(0)
摘要:You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : L 阅读全文
posted @ 2017-07-18 22:11 immjc 阅读(129) 评论(0) 推荐(0)
摘要:Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there ar 阅读全文
posted @ 2017-07-18 21:40 immjc 阅读(126) 评论(0) 推荐(0)
摘要:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example,Given nums = [0, 1, 阅读全文
posted @ 2017-07-18 15:25 immjc 阅读(139) 评论(0) 推荐(0)
摘要:Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each eleme 阅读全文
posted @ 2017-07-18 15:03 immjc 阅读(148) 评论(0) 推荐(0)
摘要:Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202" Example 2: Input: -7 Output: "-10" Note: The input will 阅读全文
posted @ 2017-07-18 14:46 immjc 阅读(169) 评论(0) 推荐(0)
摘要:Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the distance between iand j equals 阅读全文
posted @ 2017-07-18 14:17 immjc 阅读(162) 评论(0) 推荐(0)
摘要:A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents 阅读全文
posted @ 2017-07-17 21:31 immjc 阅读(161) 评论(0) 推荐(0)
摘要:Reverse a singly linked list. Hint: A linked list can be reversed either iteratively or recursively. Could you implement both? 迭代。 递归。 阅读全文
posted @ 2017-07-17 16:27 immjc 阅读(123) 评论(0) 推荐(0)
摘要:Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Example 2: Note: 将数组按照逆序排序后,如果数组元素都是整数, 阅读全文
posted @ 2017-07-17 16:23 immjc 阅读(128) 评论(0) 推荐(0)
摘要:Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Example 2: Note: 求给定字母组成的最长回文串,使用map记录元 阅读全文
posted @ 2017-07-17 15:55 immjc 阅读(136) 评论(0) 推荐(0)
摘要:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 将一串罗马数字转换为整数,首先使用map建立罗马字母与数字的表示法则。然后从右向左遍 阅读全文
posted @ 2017-07-17 15:20 immjc 阅读(113) 评论(0) 推荐(0)
摘要:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr 阅读全文
posted @ 2017-07-17 12:33 immjc 阅读(146) 评论(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 @ 2017-07-16 21:55 immjc 阅读(128) 评论(0) 推荐(0)
摘要: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 identical a 阅读全文
posted @ 2017-07-16 21:46 immjc 阅读(133) 评论(0) 推荐(0)
摘要: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 -> 2 -> 3 - 阅读全文
posted @ 2017-07-16 21:17 immjc 阅读(111) 评论(0) 推荐(0)
摘要: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 that the 阅读全文
posted @ 2017-07-16 21:03 immjc 阅读(115) 评论(0) 推荐(0)

上一页 1 ··· 7 8 9 10 11 12 13 14 下一页