C++17在业务代码中最好用的十个特性
C++17在业务代码中最好用的十个特性
自从步入现代C++时代开始,C++语言标准形成了三年一个版本的惯例:C++11标志着现代C++的开端,C++14在11的基础上查缺补漏,并未加入许多新特性,而C++17作为C++11后的第一个大版本,标志着现代C++逐渐走向成熟。WXG编译器升级到gcc7.5已有一段时间,笔者所在项目组也已经将全部代码升级到C++17。在使用了c++17一年多之后,笔者总结了C++17在业务代码中最好用的十个特性。
JustMySocks+Qv2ray极简教程
justmysocks 官网链接
Tree Traversal
Tree traversal algorithms: pre_order, in_order, post_order
SweepLine
SweepLine algorithm for finding all intersections
Palinedrome Number
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.
String to Integer (atoi)
Implement
atoi
which converts a string to an integer.Daily temperatures
Given a list of daily temperatures
T
, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put0
instead.Edit distance
Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.
Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer.
Palindromic Substrings
Given a string, your task is to count how many palindromic substrings in this string.
Task Scheduler
Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original order. Each task could be done in one interval. For each interval, CPU could finish one task or just be idle.
Merge Two Binary Trees
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.
Zigzag Conversion
The string
"PAYPALISHIRING"
is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)Shortest Unsorted Continuous Subarray
Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.
Subarray Sum Equals K
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.
Diameter of Binary Tree
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 longest path between any two nodes in a tree. This path may or may not pass through the root.
Longest Palindromic Substring
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
Target Sum
You are given a list of non-negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols
+
and-
. For each integer, you should choose one from+
and-
as its new symbol.Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.
Find all Anagrams in a String
Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s.
Path Sum III
You are given a binary tree in which each node contains an integer value.
Partition Equal Subset Sum
Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.
Queue Reconstruction by Height
Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers
(h, k)
, whereh
is the height of the person andk
is the number of people in front of this person who have a height greater than or equal toh
. Write an algorithm to reconstruct the queue.Median of Two Sorted Array
There are two sorted arrays nums1 and nums2 of size m and n respectively.
Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.
Divide Two Integers
Given two integers
dividend
anddivisor
, divide two integers without using multiplication, division and mod operator.Implement strStr()
Implement strStr().
Remove Element
Given an array nums and a value val, remove all instances of that value in-place and return the new length.
Remove Duplicates from Sorted Array
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.
Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.
Merge K Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
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.
Valid Parentheses
Given a string containing just the characters
'('
,')'
,'{'
,'}'
,'['
and']'
, determine if the input string is valid.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 it as a linked list.
Remove Nth Node From End of List
Given a linked list, remove the n-th node from the end of list and return its head.
4 Sum
Given an array
nums
of n integers and an integertarget
, are there elements a, b, c, and d innums
such that a + b + c + d =target
? Find all unique quadruplets in the array which gives the sum oftarget
.Letter Combinations of a Phone Number
Given a string containing digits from
2-9
inclusive, return all possible letter combinations that the number could represent.3Sum Closest
Given an array
nums
of n integers and an integertarget
, find three integers innums
such that the sum is closest totarget
. Return the sum of the three integers. You may assume that each input would have exactly one solution.3Sum
Given an array
nums
of n integers, are there elements a, b, c innums
such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.
Roman to Integer
Roman numerals are represented by seven different symbols:
I
,V
,X
,L
,C
,D
andM
.Count Vowels Permutation
Given an integer
n
, your task is to count how many strings of lengthn
can be formed under the following rules:Path with Maximum Gold
In a gold mine
grid
of sizem * n
, each cell in this mine has an integer representing the amount of gold in that cell,0
if it is empty.Longest Arithmetic Subsequence of Given Difference
Given an integer array
arr
and an integerdifference
, return the length of the longest subsequence inarr
which is an arithmetic sequence such that the difference between adjacent elements in the subsequence equalsdifference
.Play with Chips
There are some chips, and the i-th chip is at position
chips[i]
.Minimum Moves to Reach Target with Rotations
In an
n*n
grid, there is a snake that spans 2 cells and starts moving from the top left corner at(0, 0)
and(0, 1)
. The grid has empty cells represented by zeros and blocked cells represented by ones. The snake wants to reach the lower right corner at(n-1, n-2)
and(n-1, n-1)
.Remove All adjacent Duplicates in String II
Given a string
s
, a k duplicate removal consists of choosingk
adjacent and equal letters froms
and removing them causing the left and the right side of the deleted substring to concatenate together.Get Equal Substrings Within Budget
You are given two strings
s
andt
of the same length. You want to changes
tot
. Changing thei
-th character ofs
toi
-th character oft
costs|s[i] - t[i]|
that is, the absolute difference between the ASCII values of the characters.Unique number of Occurrences
Given an array of integers
arr
, write a function that returnstrue
if and only if the number of occurrences of each value in the array is unique.Sort Items by Groups Respecting Dependencies
There are
n
items each belonging to zero or one ofm
groups wheregroup[i]
is the group that thei
-th item belongs to and it’s equal to-1
if thei
-th item belongs to no group. The items and the groups are zero indexed. A group can have no item belonging to it.Smallest String with Swaps
You are given a string
s
, and an array of pairs of indices in the stringpairs
wherepairs[i] = [a, b]
indicates 2 indices(0-indexed) of the string.Ugly number III
Write a program to find the
n
-th ugly number.Minimum Absolute Difference
Given an array of distinct integers
arr
, find all pairs of elements with the minimum absolute difference of any two elements.Integer to Roman
Roman numerals are represented by seven different symbols:
I
,V
,X
,L
,C
,D
andM
.Critical Connections in a Network
There are
n
servers numbered from0
ton-1
connected by undirected server-to-serverconnections
forming a network whereconnections[i] = [a, b]
represents a connection between serversa
andb
. Any server can reach any other server directly or indirectly through the network.K-Concatenation Maximum Sum
Given an integer array
arr
and an integerk
, modify the array by repeating itk
times.Reverse Substrings Between Each Pair of Parentheses
You are given a string
s
that consists of lower case English letters and brackets.Number of Valid Words for Each Puzzle
With respect to a given
puzzle
word
validCan Make Palindrome from Substring
Given a string
s
, we make queries on substrings ofs
.Diet Plan Performance
A dieter consumes
calories[i]
calories on thei
-th day. For every consecutive sequence ofk
days, they look at T, the total calories consumed during that sequence ofk
days:Prime Arrangements
Return the number of permutations of 1 to
n
so that prime numbers are at prime indices (1-indexed.)Container With Most Water
Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.
Regular Expression Matching
Given an input string (
s
) and a pattern (p
), implement regular expression matching with support for'.'
and'*'
.Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
A Latex Presentation/Poster Template for NYU
Recently, when I was working on my capstone paper for my undergraduate degree at NYUAD, I felt obliged to follow NYU’s visual guideline when making my presentations and posters. It turned out easier than I thought to adopt NYU’s color scheme. So I decided to make a template available to everyone at NYU. I have included styles for NYU, NYU Abu Dhabi and NYU Shanghai.