Sort by

recency

|

3098 Discussions

|

  • + 0 comments

    Here is Subarray Division solution in python, java, c++, c and javascript - https://programmingoneonone.com/hackerrank-subarray-division-2-problem-solution.html

  • + 0 comments

    Interesting post on Subarray Division! Reading through all these patterns and combinations makes me think about the endless flavor possibilities in tropical smoothie drinks — so many ways to mix and match for the perfect result and visit site: https://tropicalsmothiemenu.com/

  • + 0 comments

    Interesting post on Subarray Division! Reading through all these patterns and combinations makes me think about the endless flavor possibilities in https://tropicalsmothiemenu.com/ — so many ways to mix and match for the perfect result!

  • + 0 comments
    import java.io.*;
    import java.util.stream.Stream;
    
    public class TheBirthdayBar {
    
        public static void main(String[] args) {
            try (var br = new BufferedReader(new InputStreamReader(System.in));
                 var bw = new BufferedWriter(new OutputStreamWriter(System.out))) {
    
                int n = Integer.parseInt(br.readLine());
                int[] squares = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
                String[] line = br.readLine().split(" ");
                int day = Integer.parseInt(line[0]);
                int month = Integer.parseInt(line[1]);
    
                int result = countWays(squares, day, month);
    
                bw.write(String.valueOf(result));
                bw.flush();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    
        private static int countWays(int[] squares, int targetSum, int segmentLength) {
            if (squares.length < segmentLength) {
                return 0;
            }
            int currentSum = 0;
            for (int i = 0; i < segmentLength; i++) {
                currentSum += squares[i];
            }
            int validWays = (currentSum == targetSum) ? 1 : 0;
            for (int i = segmentLength; i < squares.length; i++) {
                currentSum = currentSum - squares[i - segmentLength] + squares[i];
                if (currentSum == targetSum) {
                    validWays++;
                }
            }
            return validWays;
        }
    }
    
  • + 0 comments

    Really cool seeing so many clean solutions here — the sliding window approach seems to be the favorite, and for good reason. It’s efficient, easy to grasp once you visualize how the window moves, and works perfectly for problems like “Birthday Chocolate.”

    What I find fascinating is how algorithmic problem-solving trains your brain for real-world analysis — Each move (or loop) has a purpose, and small optimizations make a big difference. Speaking of that, I recently read about the an event, which highlighted how mental precision and strategy are just as important as physical strength — a lot like writing efficient code.