Skip to content

Instantly share code, notes, and snippets.

View stexuq's full-sized avatar

Stella Qian Xu stexuq

View GitHub Profile
class Solution {
public:
/**
* @param nums: a rotated sorted array
* @return: the minimum number in the array
*/
int findMin(vector<int> &nums) {
int n = nums.size();
int start = 0, end = n - 1;
if (nums[start] < nums[end]) return nums[start];
/**
* class SVNRepo {
* public:
* static bool isBadVersion(int k);
* }
* you can use SVNRepo::isBadVersion(k) to judge whether
* the kth code version is bad or not.
*/
class Solution {
public:
@stexuq
stexuq / subsets.java
Created October 8, 2021 05:57
subsets (java)
public class Solution {
/**
* @param nums: A set of numbers
* @return: A list of lists
*/
public List<List<Integer>> subsets(int[] nums) {
Arrays.sort(nums);
return helper(nums, nums.length - 1);
}
@stexuq
stexuq / subsets.cc
Last active October 8, 2021 05:47
Subsets (C++)
class Solution {
public:
/**
* @param nums: A set of numbers
* @return: A list of lists
*/
vector<vector<int>> subsets(vector<int> &nums) {
if (nums.size() == 0) {
vector<vector<int>> res;
vector<int> empty;
https://docs.oracle.com/en/java/javase/11/install/installation-jdk-macos.html#GUID-F575EB4A-70D3-4AB4-A20E-DBE95171AB5F
@stexuq
stexuq / gist:e4be64da31fd2cbe9ff650f5322c86e2
Last active June 12, 2020 06:20
Not use Scene Delegate when creating a new Xcode iOS Project
1. Remove Scene delegate methods from AppDelegate and delete the Scene delegate file.
2. remove UIApplicationSceneManifest from Info.plist.
3. we need to add a window property in AppDelegate `@property(nonatomic, strong) UIWindow *window;` For Swift, add `var window: UIWindow?`
@stexuq
stexuq / gist:c92d5e45dce719fc1188c46e6c46bf26
Created May 22, 2020 05:48
Nested Route in react-router-dom v4+
"react-router": "^1.0.3",
"react-router-dom": "^5.2.0",
import {BrowserRouter as Router, Route, Link, Switch} from 'react-router-dom';
// Nested Route
ReactDOM.render(
(
<Router>
<Switch>