Skip to content

Instantly share code, notes, and snippets.

@igavrysh
igavrysh / leetcode_2337.java
Created December 5, 2024 05:48
2337. Move Pieces to Obtain a String
/*
https://leetcode.com/problems/move-pieces-to-obtain-a-string
2337. Move Pieces to Obtain a String
Solved
Medium
You are given two strings start and target, both of length n. Each string consists only of the characters 'L', 'R', and '_' where:
The characters 'L' and 'R' represent pieces, where a piece 'L' can move to the left only if there is a blank space directly to its left, and a piece 'R' can move to the right only if there is a blank space directly to its right.
The character '_' represents a blank space that can be occupied by any of the 'L' or 'R' pieces.
@igavrysh
igavrysh / Solution.java
Created October 6, 2024 00:46
Leetcode2062 solution
// https://leetcode.com/problems/count-vowel-substrings-of-a-string/
// https://youtu.be/hGH_Z4_jMBI
///
class Solution {
public int countVowelSubstrings(String word) {
int n = word.length();
int[] fq = new int[26];
int k = 0; int l = 0;
int res = 0;
for (int r = 0; r < n; r++) {
/// https://leetcode.com/problems/intervals-between-identical-elements
///
class Solution {
public long[] getDistances(int[] arr) {
int n = arr.length;
HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
for (int i=0; i<n; i++) {
ArrayList<Integer> a = map.get(arr[i]);
if (a == null) {
a = new ArrayList<>();

13 Sep 2024

2265. Count Nodes Equal to Average of Subtree
809. Expressive Words
106. Construct Binary Tree from Inorder and Postorder Traversal
386. Lexicographical Numbers

6 Sep 2024

# to control bluetooth
bluetoothctrl
# and? maybe
blueman
# for application launcher
bemenu
# to view apps
waybar
@igavrysh
igavrysh / Solution.java
Created May 13, 2024 15:33
Leetcode 857. Minimum Cost to Hire K Workers Attempt#1
/*
857. Minimum Cost to Hire K Workers
https://leetcode.com/problems/minimum-cost-to-hire-k-workers
Attempt#1
*/
class Solution {
public double mincostToHireWorkers(int[] quality, int[] wage, int k) {
return 0.0;
}
@igavrysh
igavrysh / Solution.java
Created May 13, 2024 15:32
Leetcode 1928. Minimum Cost to Reach Destination in Time Attempt#1
/*
1928. Minimum Cost to Reach Destination in Time
https://leetcode.com/problems/minimum-cost-to-reach-destination-in-time
*/
class Solution {
public int minCost(int maxTime, int[][] edges, int[] passingFees) {
int src = 0;
int n = 0;
@igavrysh
igavrysh / Solution.java
Created May 13, 2024 15:30
Leetcode 1530. Number of Good Leaf Nodes Pairs Attempt#1
/**
1530. Number of Good Leaf Nodes Pairs
Attempt#1
https://leetcode.com/problems/number-of-good-leaf-nodes-pairs/
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode() {}