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
| <?xml version="1.0" encoding="utf-8"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| package="com.example.mock_android" | |
| android:versionCode="1" | |
| android:versionName="1.0" > | |
| <uses-sdk | |
| android:minSdkVersion="8" | |
| android:targetSdkVersion="21" /> |
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 com.sample; | |
| /** | |
| * Created by Maksim on 3/15/2016. | |
| */ | |
| public class Foo { | |
| public void bar() { | |
| System.out.print("bar"); |
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 etf; | |
| public class A { | |
| public int t; | |
| A(int t) { | |
| this.t = t; | |
| } |
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 mian; | |
| import sample.PublicInstance; | |
| public class Main { | |
| public static void main(String[] args) { | |
| System.out.println(PublicInstance.STRING); | |
| } |
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
| class DoubleFoo { | |
| private volatile Helper d_helper; | |
| public Helper getHelper() { | |
| Helper result = d_helper; | |
| if (result == null) { | |
| synchronized(this) { | |
| result = d_helper; | |
| if (result == null) { | |
| helper = result = new Helper(); | |
| } |
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
| public static void myUsFlagSort(int[] input, int stripeLen, int red, int white) { | |
| // Input: 1, 2, 1, 1, 1, 2, 2, 2 | |
| // Output: 1, 1, 2, 2, 1, 1, 2, 2 | |
| // Let 1 be red | |
| // Let 2 be white | |
| // Red stripes are at 0, 1, 4, 5 ... | |
| int redIndex = 0; |
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
| private static void checkMyUsFlagSortInput(int[] input, int red, int white) { | |
| if (input.length < 4) { | |
| throw new IllegalArgumentException("the min input size is 4"); | |
| } | |
| if (input.length % 2 != 0) { | |
| throw new IllegalArgumentException("the input size " + input.length + " is wrong"); | |
| } | |
| int redCount = 0; | |
| int whiteCount = 0; | |
| for (int elem : input) { |
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
| public static void russianFlagProblem(int[] input, int red, int white, int blue) { | |
| // input: 1, 2, 3, 1, 1, 2, 3, 1, 1 | |
| // Dutch: 1, 1, 1, 1, 1, 2, 2, 3, 3 | |
| // (1 - red, 2 - white, 3 - blue) | |
| // Russian: 2 - white, 3 - blue, 1 - red | |
| // output: 2, 2, 3, 3, 1, 1, 1, 1, 1 | |
| int i = 0; // the end of the white region (exclusive) |
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
| public class Main { | |
| public static void main(String[] args) { | |
| System.out.println(getPermutations("bbca", "abbca")); | |
| } | |
| private static Set<String> getPermutations(String source, String input) { | |
| if (source == null || input == null || source.isEmpty() || input.isEmpty()) { | |
| return null; | |
| } |
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
| private static long fibTailRec(long n, long c, long pPrev, long prev) { | |
| if (c == 0) { | |
| pPrev = 0; | |
| } else if (c == 1) { | |
| prev = 1; | |
| } | |
| if (c == n) { | |
| return prev; | |
| } else { | |
| return fibTailRec(n, ++c, prev, pPrev + prev); |
OlderNewer