
C/C++
文章平均质量分 54
Terumii
计算机图形学、多媒体通信
展开
-
C/C++获取大型文件的大小
C/C++获取大型文件的大小(体积)原创 2016-11-05 12:53:28 · 1471 阅读 · 2 评论 -
LeetCode - easy-628. Maximum Product of Three Numbers
问题Given an integer array, find three numbers whose product is maximum and output the maximum product.Example 1:Input: [1,2,3]Output: 6Example 2:Input: [1,2,3,4]Output: 24Note: * The length of the gi原创 2017-11-13 17:19:30 · 222 阅读 · 0 评论 -
LeetCode - easy-682. Baseball Game
问题You’re now a baseball game point recorder.Given a list of strings, each string can be one of the 4 following types:Integer (one round's score): Directly represents the number of points you get in thi原创 2017-11-13 17:19:59 · 256 阅读 · 0 评论 -
LeetCode - easy-695. Max Area of Island
问题Given a non-empty 2D array grid of 0’s and 1’s, an island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are su原创 2018-01-30 22:57:56 · 247 阅读 · 0 评论 -
LeetCode - easy-697. Degree of an Array
问题Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.Your task is to find the smallest possible length o原创 2018-01-30 22:59:02 · 196 阅读 · 0 评论 -
LeetCode - easy-720. Longest Word in Dictionary
720. Longest Word in DictionaryGiven a list of strings words representing an English Dictionary, find the longest word in words that can be built one character at a time by other words in words. If原创 2018-01-30 22:59:42 · 202 阅读 · 0 评论 -
LeetCode - easy-744. Find Smallest Letter Greater Than Target
问题Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the list that is larger than the given target.Letters原创 2018-01-30 23:00:09 · 270 阅读 · 0 评论 -
LeetCode - easy-747. Min Cost Climbing Stairs
问题On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top原创 2018-01-30 23:01:16 · 200 阅读 · 0 评论 -
LeetCode - easy-762. Prime Number of Set Bits in Binary Representation
竞赛问题Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation.(Recall that the number of set bits an in原创 2018-01-30 23:01:44 · 329 阅读 · 0 评论 -
hard-480. Sliding Window Median
问题Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples: [2,3,4] , the medi原创 2018-01-30 23:03:01 · 242 阅读 · 0 评论 -
leetcode-3-Longest Substring Without Repeating Characters
一、问题Given a string, find the length of the longest substring without repeating characters.Examples:Given “abcabcbb”, the answer is “abc”, which the length is 3.Given “bbbbb”, the answer is “b”原创 2018-01-30 23:03:28 · 280 阅读 · 0 评论 -
LeetCode - easy-344. Reverse String
问题Write a function that takes a string as input and returns the string reversed.Example:Given s = “hello”, return “olleh”.代码class Solution {public: string reverseString(string s) { //方法一:原创 2017-11-13 17:19:00 · 194 阅读 · 0 评论 -
LeetCode - easy-141. 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?思考此题初看简单,实则容易走歪。使用 哈希表 unordered_set 来实现的话,就是将指针存进去,每次存之前看set里有没有这个指针,有则说明有cycle。时间复杂度和空间原创 2017-11-13 17:18:31 · 224 阅读 · 0 评论 -
LeetCode - 98. Validate Binary Search Tree
问题 :MediumGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node’s key.原创 2017-11-02 23:37:41 · 234 阅读 · 0 评论 -
C++中类对象的内存布局和占用空间
一个Class对象需要占用的内存空间:*非静态成员变量总合。*加上编译器为了CPU计算,作出的数据对齐处理。*加上为了支持虚函数,产生的额外负担。转载 2017-05-21 23:01:12 · 461 阅读 · 0 评论 -
详解栈区、堆区、全局区、文字常量区、程序代码区
堆 & 栈 的详细对比转载 2017-05-21 23:16:38 · 255 阅读 · 0 评论 -
LeetCode 1. Two Sum
LeetCode 1. Two Sun使用unordered_map。原创 2017-10-20 23:00:19 · 175 阅读 · 0 评论 -
LeetCode - 409. Longest Palindrome
问题Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example “Aa” is not consid原创 2017-11-07 22:15:14 · 189 阅读 · 0 评论 -
LeetCode - 530. Minimum Absolute Difference in BST
问题 easyGiven a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.Example:Input: 1 \ 3 / 2Output:1Explanation:The mini原创 2017-11-07 22:15:47 · 238 阅读 · 0 评论 -
LeetCode - 653. Two Sum IV - Input is a BST
问题 easyGiven a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.Example 1:Input: 5 / \ 3 6 / \原创 2017-11-07 22:16:31 · 222 阅读 · 0 评论 -
LeetCode - 2. Add Two Numbers
问题You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return原创 2017-10-22 21:33:11 · 214 阅读 · 0 评论 -
LeetCode - 19. Remove Nth Node From End of List
问题Given a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked list原创 2017-10-22 21:34:47 · 225 阅读 · 0 评论 -
LeetCode 24. Swap Nodes in Pairs
问题Given a linked list, swap every two adjacent nodes and return its head.For example, Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You may原创 2017-10-26 10:29:42 · 349 阅读 · 0 评论 -
LeetCode - 48. Rotate Image
问题:You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).原创 2017-11-02 23:36:33 · 221 阅读 · 0 评论 -
leetcode-21-Merge Two Sorted Lists
一、问题Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.二、代码/** * Definition for singly-linked lis原创 2018-01-30 23:05:39 · 267 阅读 · 0 评论