leetcode
ningto.com
个人站点:https://ningto.com
展开
-
Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. 代码: class Solution { public: bool isPalindrome(int x) { if (x < 0) { return false; } else if (x < 10) { retur原创 2015-04-17 15:49:32 · 437 阅读 · 0 评论 -
Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where原创 2015-04-17 15:38:44 · 460 阅读 · 0 评论 -
Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determi原创 2015-04-17 15:30:43 · 461 阅读 · 0 评论 -
Linked List Cycle
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 代码: /** * Definition for singly-linked list. * struct ListNode { * int val; *原创 2015-04-17 15:36:44 · 482 阅读 · 0 评论 -
Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array.原创 2015-04-17 15:34:56 · 388 阅读 · 0 评论 -
Rotate 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: Try to come up as many solutions as you can,原创 2015-04-17 15:46:55 · 551 阅读 · 0 评论 -
Number of 1 Bits
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 integer ’11' has binary representation 0000000000原创 2015-04-17 15:41:23 · 1709 阅读 · 0 评论 -
Excel Sheet Column Number
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ...原创 2015-04-17 15:49:36 · 530 阅读 · 0 评论 -
Majority Element
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 array is non-empty and the majority element always e原创 2015-04-17 15:44:51 · 477 阅读 · 0 评论 -
Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative. 代码: class Solution { public: string原创 2015-04-17 15:41:19 · 456 阅读 · 0 评论 -
Reverse Bits
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011原创 2015-04-17 15:55:13 · 717 阅读 · 0 评论