Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb723e86

Browse files
edit 523
1 parent74feddd commitb723e86

File tree

1 file changed

+9
-0
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+9
-0
lines changed

‎src/main/java/com/fishercoder/solutions/_523.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
*/
2828
publicclass_523 {
2929

30+
/**reference: https://discuss.leetcode.com/topic/80793/java-o-n-time-o-k-space/20
31+
*
32+
* "The reason we use modulus is:
33+
* (a+(n*x))%x is same as (a%x)
34+
* e.g. in case of the array [23,2,6,4,7] the running sum is [23,25,31,35,42]
35+
* and the remainders are [5,1,1,5,0].
36+
* We got reminder 5 at index 0 and at index 3.
37+
* That means, in between these two indexes we must have added a number which is multiple of the k.
38+
* Hope this clarifies your doubt :)"*/
3039
publicbooleancheckSubarraySumOnTimeO1Space(int[]nums,intk) {
3140
Map<Integer,Integer>map =newHashMap<>();
3241
map.put(0, -1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp