随笔分类 -  Leetcode (C++)

上一页 1 2 3 4 5 6 ··· 10 下一页

68. Text Justification
摘要:Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.You shoul 阅读全文

posted @ 2016-11-02 20:38 joannae 阅读(170) 评论(0) 推荐(0)

58. Length of Last Word (String)
摘要:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word 阅读全文

posted @ 2016-10-26 03:49 joannae 阅读(158) 评论(0) 推荐(0)

33. Search in Rotated Sorted Array (Array;Divide-and-Conquer)
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target va 阅读全文

posted @ 2016-09-16 21:10 joannae 阅读(182) 评论(0) 推荐(0)

207. Course Schedule(Graph; BFS)
摘要:There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to... 阅读全文

posted @ 2015-12-31 16:44 joannae 阅读(284) 评论(0) 推荐(0)

206. Reverse Linked List (List)
摘要:Reverse a singly linked list./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) :... 阅读全文

posted @ 2015-12-28 19:08 joannae 阅读(164) 评论(0) 推荐(0)

205. Isomorphic Strings (Map)
摘要: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 occurrences... 阅读全文

posted @ 2015-12-28 18:53 joannae 阅读(183) 评论(0) 推荐(0)

204. Count Primes (Integer)
摘要:Count the number of prime numbers less than a non-negative number, n.思路:寻找质数的方法class Solution {public: int countPrimes(int n) { int num = 0;... 阅读全文

posted @ 2015-12-25 06:50 joannae 阅读(175) 评论(0) 推荐(0)

203. Remove Linked List Elements (List)
摘要:Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 -->... 阅读全文

posted @ 2015-12-17 09:06 joannae 阅读(167) 评论(0) 推荐(0)

202. Happy Number (INT)
摘要:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文

posted @ 2015-12-17 08:31 joannae 阅读(357) 评论(0) 推荐(0)

201. Bitwise AND of Numbers Range (Bit)
摘要:Given a range [m, n] where 0 >= 1; n >>= 1; shift++; } return (m << shift); }}; 阅读全文

posted @ 2015-12-17 08:14 joannae 阅读(236) 评论(0) 推荐(0)

200. Number of Islands (Graph)
摘要:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen... 阅读全文

posted @ 2015-12-16 14:56 joannae 阅读(194) 评论(0) 推荐(0)

199. Binary Tree Right Side View (Tree, Stack)
摘要:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For exam... 阅读全文

posted @ 2015-12-16 14:18 joannae 阅读(199) 评论(0) 推荐(0)

198. House Robber(Array; DP)
摘要: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 yo... 阅读全文

posted @ 2015-12-16 13:29 joannae 阅读(189) 评论(0) 推荐(0)

191. Number of 1 Bits (Int; Bit)
摘要: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 i... 阅读全文

posted @ 2015-12-16 12:37 joannae 阅读(162) 评论(0) 推荐(0)

190. Reverse Bits (Int; Bit)
摘要:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 阅读全文

posted @ 2015-12-16 12:29 joannae 阅读(205) 评论(0) 推荐(0)

189. Rotate Array(Array)
摘要:Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:... 阅读全文

posted @ 2015-12-16 10:58 joannae 阅读(161) 评论(0) 推荐(0)

188. Best Time to Buy and Sell Stock IV (Array; DP)
摘要:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complet... 阅读全文

posted @ 2015-12-16 08:46 joannae 阅读(137) 评论(0) 推荐(0)

187. Repeated DNA Sequences (String; Bit)
摘要:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to ... 阅读全文

posted @ 2015-12-15 10:31 joannae 阅读(200) 评论(0) 推荐(0)

179. Largest Number(INT, String)
摘要:Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed nu... 阅读全文

posted @ 2015-12-09 17:11 joannae 阅读(253) 评论(0) 推荐(0)

137. Single Number II (Bit)
摘要:Given an array of integers, every element appears three times except for one. Find that single one. Note:Your algorithm should have a linear runtime c 阅读全文

posted @ 2015-12-06 07:25 joannae 阅读(185) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 ··· 10 下一页

导航