This file contains 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
fun longestPalindrome(input: String) : String { | |
var start = 0; | |
var maxLength = 1 | |
fun expandAroundCenter(str : String, left: Int, right: Int) { | |
var low = left; | |
var high = right | |
while(low >= 0 && high < str.length && str[low] == str[high]) { | |
if (high - low + 1 > maxLength) { |
This file contains 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
/** | |
* https://leetcode.com/problems/add-two-numbers/description/ | |
* | |
* Definition for singly-linked list. | |
* class ListNode(var `val`: Int = 0) { | |
* var next: ListNode? = null | |
* } | |
*/ | |
class Solution { | |
fun addTwoNumbers(l1: ListNode?, l2: ListNode?): ListNode? { |
This file contains 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 testing1234 { | |
@Test | |
fun yo() { | |
val testArray = IntArray(3) | |
testArray.set(0, 1) | |
testArray.set(1, 2) | |
testArray.set(2, 1) | |
println(permute(testArray)) |
This file contains 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 i_introduction._0_Hello_World | |
import org.junit.Test | |
import kotlin.collections.ArrayList | |
class nqueens() { | |
@Test | |
fun yo() { |
This file contains 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 hackerrank | |
import org.junit.Test | |
import java.util.* | |
import kotlin.collections.ArrayList | |
class sumsets { | |
@Test fun yo() { | |
val lists = findSubsets(Arrays.asList(1,2,3,5), 5) | |
println(lists) |
This file contains 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 __00_Knapsack { | |
val array = arrayOf(Pair(1,1), Pair(3,4), Pair(4,5), Pair(5,7)) | |
@Test fun yo() { | |
val row1: IntArray = intArrayOf(0, 0, 0, 0, 0, 0, 0, 0); | |
val row2: IntArray = intArrayOf(0, 0, 0, 0, 0, 0, 0, 0); | |
val row3: IntArray = intArrayOf(0, 0, 0, 0, 0, 0, 0, 0); | |
val row4: IntArray = intArrayOf(0, 0, 0, 0, 0, 0, 0, 0); |
This file contains 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
/* | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<script src="https://unpkg.com/@reactivex/rxjs@5.0.3/dist/global/Rx.js"></script> | |
<script src="//fb.me/react-0.13.1.js"></script> | |
<div id="root"> | |
</div> | |
</body> |
This file contains 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
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
// initial setup | |
View headerView = Utils.createDynamicView(this); | |
int viewResource = R.layout.footer_view; | |
// setting STATE tells us how to set up our logic |
This file contains 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
// we want the header to span the full width | |
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { | |
@Override | |
public int getSpanSize(int position) { | |
switch(STATE) { | |
case HEADER: | |
if (position == 0) { | |
return spanCount; | |
} | |
return 1; |
This file contains 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
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() { | |
@Override | |
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { | |
int position = parent.getChildAdapterPosition(view); | |
int padding = Utils.dpToPx(getResources(), 16); | |
if (position == 0 && (STATE == HEADER || STATE == BOTH)) { | |
outRect.left = padding; | |
outRect.right = padding; | |
outRect.top = padding; |