- 博客(18)
- 收藏
- 关注
原创 Second Highest Salary
PROBLEM:Write a SQL query to get the second highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+For e...
2018-03-20 22:15:03 156
原创 Add Digits
PROBLEM:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one...
2018-03-20 00:59:15 145
原创 Degree of an Array【一个数组的度】
PROBLEM: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...
2018-03-19 20:50:17 244
原创 【C++】new对象时有无()的区别
情况1:类中显式定义了默认构造函数此时new Test()和new Test并无区别,都会调用定义的构造函数,所以下面程序中的输出结果一样。class Test {private: int N;public: Test() { N = 1; } int GetNum() { return N; }};int main(){ Test* AA = new Test(); Tes...
2018-03-16 14:57:30 432
原创 Find Pivot Index
POBLEM:Given an array of integers nums, write a method that returns the "pivot" index of this array.We define the pivot index as the index where the sum of the numbers to the left of the index is equa...
2018-03-14 19:30:11 150
原创 Remove Linked List Elements
PROBLEM: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 --> 3 --> 4 -->...
2018-03-12 22:03:17 136
原创 Isomorphic Strings
PROBLEM: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 of a character must be replaced with anot...
2018-03-12 21:24:39 125
原创 Find Smallest Letter Greater Than Target【找到比目标数大的数字中的最小数】【二分的终止判断条件】
PROBLEM: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.Le...
2018-03-11 11:28:08 301
原创 Min Cost Climbing Stairs
PROBLEM: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 t...
2018-03-11 00:24:05 167
原创 FreeNOS学习笔记(一)
本人系统环境为 ubantu 16.04 LTS1、下载源文件 和 ios镜像文件下载链接(download目录中):http://www.freenos.org/2、文件位置:将源文件包和FreeNOS.ios镜像文件都放在FreeNOS文件夹下3、终端中安装虚拟机qemu执行命令:sudo apt-get install qemu4、创建虚拟机首先cd到文件夹FreeNOS中,然后利用 qem...
2018-03-10 00:05:47 6924
原创 【C++】sizeof各种类型的大小
#include <iostream>using namespace std;////////// 测试基础类型 //////////int GetArraySize(char str[]){ return sizeof(str);}void TestSizeofBase(){ cout << "////////// 测试基础类型 ///...
2018-03-09 14:16:24 800
原创 Minimum Distance Between BST Nodes
PROBLEM:Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree.Example :Input: root = [4,2,6,1,3,null,null]O...
2018-03-09 01:37:08 362
原创 【C++】琐碎知识点整理记录
1、要将一个字母大小写变换一下,可以用这种方法:char ss^=32; //s^=(1<<5)也可以2、创建set并初始化,利用set判断某个元素是否在set中。set类是有序的。set<char> setJ(std::begin(setK),std::end(setK)); // 创建K的副本for(char s:S) if(setJ...
2018-03-08 23:54:03 309
原创 Minimum Depth of Binary Tree
PROBLEM:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.SOLVE:/** * Definition for a bina...
2018-03-07 13:44:06 144
原创 Convert Sorted Array to Binary Search Tree
PROBLEM:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth ...
2018-03-06 19:31:32 115
原创 Binary Tree Level Order Traversal II【二叉树层序转换】
PROBLEM:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null...
2018-03-06 15:57:10 157
原创 Climbing Stairs【动规递推】
PROBLEM:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a posi...
2018-03-01 21:17:32 213
原创 Add Binary【二进制相加】
PROBLEM:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".SOLVE(C++):class Solution{public: string addBinary(string a, string b){ s...
2018-03-01 19:29:13 244
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人