Home
fozu的技术站
Cancel

algorithm - middle node

Problem Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. Example: Input: head = [1,2,3,4,5] Outpu...

algorithm - merge two sorted list

Problem You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists...

algorithm - isSubsequence

Problem Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (...

algorithm - reverse list

Problem Given the head of a singly linked list, reverse the list, and return the reversed list. Constraints: The number of nodes in the list is the range [0, 5000]. -5000 <= Node.val <...

algorithm - isomorphic strings

Problem Given two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be re...

cpp extern

Example extern "C" void foo() { } #ifdef __cplusplus extern "C" { #endif //__cplusplus void foo(); void bar(); #ifdef __cplusplus } #endif //__cplusplus Note 用extern “C” 修饰的代码,编译器将...

cpp reference

C++中的引用相当于别名 Example int age = 10; // 引用, refAge相当于age的别名 int &refAge = age; refAge = 20; // c pointer int *agePtr = &age; void swap1(int* a, int* b) { int tmp = *a; *a = *b; *b =...

cpp constructor

Example class Student { int m_age; Student() { this.m_age = 0; } Student(int age) { this.m_age = age; } }; 关于默认构造函数 如果有初始化工作要做,比如成员有默认值,在没有自定义构造函数下,编译器回生成默认的无参构造器 关于创建对象...

algorithm - find privot

Problem https://leetcode.com/problems/find-pivot-index/?envType=study-plan&id=level-1 Given an array of integers nums, calculate the pivot index of this array. The pivot index is the index w...

algorithm - running sum of 1d array

Problem https://leetcode.com/problems/running-sum-of-1d-array/?envType=study-plan&id=level-1 Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). ...