Skip to content

Instantly share code, notes, and snippets.

View wkdalsgh192's full-sized avatar
🏠
Working from home

Blue_Avocado wkdalsgh192

🏠
Working from home
View GitHub Profile
class Solution {
public int kConcatenationMaxSum(int[] arr, int k) {
//case 1 when k==1
if(k==1)
return kadanes(arr);
long sum=0;
for(int ele:arr)
sum+=ele;
public class BST {
public int numTrees(int n) {
int[] arr = new int[20];
arr[0] = 1;
arr[1] = 1;
int cnt = 0;
for (int i = 2; i <= n; i++) {
@wkdalsgh192
wkdalsgh192 / gist:3b148c2afc517a7d78f136ecc3e200d9
Created December 31, 2020 02:54
535. Encode and Decode TinyURL
import java.util.HashMap;
import java.util.Map;
public class Codec {
// Encodes a URL to a shortened URL.
private final static String prefix = "http://tinyurl.com/";
public static Map<String, String> map = new HashMap<>();
public String encode(String longUrl) {
Integer hashcode = longUrl.hashCode();
@wkdalsgh192
wkdalsgh192 / gist:4a06521adfdf5adb56573f1c97590071
Created December 30, 2020 14:18
794. Valid Tic-Tac-Toe State
public class TicTacToe {
public boolean validTicTacToe(String[] board) {
// count O and X
int cntX = 0;
int cntO = 0;
for (String str: board) {
for (char ch: str.toCharArray()) {
if (ch=='X') cntX++;
import java.util.*;
class Solution {
public boolean isRobotBounded(String instructions) {
boolean answer = false; // the robot is set to leave the circle at first
char[] arr = instructions.toCharArray();
int idx = 0;
int dir = 0;
class Solution {
public int solution(int n, int[] lost, int[] reserve) {
int[] numbers = new int[n+2];
for (int i : lost) numbers[i]--;
for (int i : reserve) numbers[i]++;
for (int i = 1; i < numbers.length-1; i++) {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wkdalsgh192
wkdalsgh192 / KMeans_.ipynb
Created September 25, 2019 10:07
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wkdalsgh192
wkdalsgh192 / DB0201EN-Week3-1-4-Analyzing-v5-py.ipynb
Created June 21, 2019 15:55
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wkdalsgh192
wkdalsgh192 / DB0201EN-Week3-1-3-SQLmagic-v3-py.ipynb
Created June 21, 2019 06:56
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.