This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application | |
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024 | |
diskCapacity:20 * 1024 * 1024 | |
diskPath:nil]; | |
[NSURLCache setSharedURLCache:URLCache]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation MyViewController | |
- (void)viewWillAppear:(BOOL)animated { | |
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) { | |
CGRect viewBounds = [self.view bounds]; | |
viewBounds.origin.y = 18; | |
viewBounds.size.height = viewBounds.size.height - 18; | |
self.view.frame = viewBounds; | |
} | |
// Some other code... | |
[super viewWillAppear:animated]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken; | |
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier; | |
import com.google.api.client.http.HttpTransport; | |
import com.google.api.client.http.apache.ApacheHttpTransport; | |
import com.google.api.client.json.JsonFactory; | |
import com.google.api.client.json.jackson2.JacksonFactory; | |
import java.util.Collections; | |
/** | |
* Hello world! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.Random; | |
class Heapifier { | |
private int[] nums; | |
/** | |
* Rearrange the elements in the given array so that it satisfy min heap property. | |
* Time comlexity: O(N) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implementation of Knuth-Morris-Pratt (KMP) Algorithm. | |
* Time complexity: | |
* (initialization) O(N) | |
* (query) O(N + M) | |
* | |
* Sample: LeetCode 686 | |
*/ | |
public class KMPSearch { | |
private final String target; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// O(NM) | |
#include <cstdio> | |
#include <cstring> | |
#include <algorithm> | |
using namespace std; | |
#define MAX 100 | |
char a[MAX],b[MAX],result[MAX]; | |
int dp[MAX+1][MAX+1]; | |
int getLcsLen(char a[], char b[]) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Objects; | |
/** | |
* https://leetcode.com/problems/longest-palindromic-substring/description/ | |
* Run time: 10 ms | |
* Time complexity: O(N) | |
* Space complexity: O(N) | |
* Keyword: palindrome, Manacher’s Algorithm | |
* | |
* Ref: https://articles.leetcode.com/longest-palindromic-substring-part-ii/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// Exercise: Web Crawler | |
// https://tour.golang.org/concurrency/10 | |
import ( | |
"fmt" | |
"sync" | |
) | |
type Fetcher interface { |